3

我想在excel中创建一个日志文件。

我创建了一个宏,它将在 ButtonInTime 单击时及时插入活动单元格。同样,在 ButtonOutTime 上单击活动单元格中的时间...

现在我想在ButtonInTime 上插入今天的日期,单击活动单元格的上一个单元格

计算 Total Log hours 并将其插入 OutTime 的下一个活动单元格

我怎样才能做到这一点?谁能帮我吗???

我试图找出解决方案,但没有找到正确的解决方案......

提前致谢....

4

1 回答 1

3

我做到了..这里面有一些硬代码....

Sub ButtonInTime_Click()
Range("A1").End(xlDown).Select

activecell.Offset(1, 0).Select
activecell.Value = Date
activecell.Offset(0, 1).Value = Time()
activecell.Offset(0, 3).Interior.Color = RGB(255, 0, 0)
activecell.Offset(0, 3).Value = "Log Not Closed!!!"


Range("A" & activecell.Row & ":E" & activecell.Row).Borders(xlEdgeTop).LineStyle = xlContinuous
Range("A" & activecell.Row & ":E" & activecell.Row).Borders(xlEdgeRight).LineStyle = xlContinuous
Range("A" & activecell.Row & ":E" & activecell.Row).Borders(xlEdgeBottom).LineStyle = xlContinuous
Range("A" & activecell.Row & ":E" & activecell.Row).Borders(xlEdgeBottom).LineStyle = xlContinuous

Range("B" & activecell.Row).Borders(xlEdgeRight).LineStyle = xlContinuous
Range("C" & activecell.Row).Borders(xlEdgeRight).LineStyle = xlContinuous
Range("D" & activecell.Row).Borders(xlEdgeRight).LineStyle = xlContinuous
Range("E" & activecell.Row).Borders(xlEdgeRight).LineStyle = xlContinuous

End Sub


Sub ButtonOutTime_Click()
Range("C1").End(xlDown).Select
activecell.Offset(1, 0).Select

activecell.Value = Time()
activecell.Offset(0, 1).Value = activecell.Value - activecell.Offset(0, -1).Value
activecell.Offset(0, 1).Interior.Color = RGB(255, 255, 255)


End Sub
于 2012-03-06T11:05:34.483 回答