我想在excel中创建一个日志文件。
我创建了一个宏,它会在ButtonInTime点击时及时插入活动单元格。同样在ButtonOutTime上的活动单元格中输出时间单击...
现在我想在 ButtonInTime点击活动单元格的上一个单元格
中插入今天的日期和 计算总日志时数&将其插入OutTime的下一个活动单元格。
我怎么能做到这一点? 任何人都可以帮助我吗???
我试图找出解决方案,但没有得到合适的解决方案......
提前致谢....
答案 0 :(得分:2)
我实现了它。这里有一些硬代码......
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