我似乎无法克服这个障碍。多次更正后错误仍然存在。
Set XlSheet = ActiveWorkbook.ActiveSheet
XlSheet.Cells(1, 15) = "Date"
lRow = XlSheet.Cells(XlSheet.Rows.Count, 1).End(xlUp).Row
Set rng = XlSheet.Range(XlSheet.Cells(2, 15), XlSheet.Cells(lRow, 5)).Select
感谢
答案 0 :(得分:2)
在OP最后评论之后编辑了关于每个循环的需要
ActiveWorkbook.ActiveSheet
没用,因为它是默认表
所以你可以只编码
Cells(1, 15) = "Date"
lRow = Cells(Rows.count, 1).End(xlUp).row
Set rng = Range(Cells(2, 15), Cells(lRow, 5))
For Each cell In rng
cell.Value = Date
Next cell
但是整个循环可以崩溃到:
rng.Value = Date
如果您计划切换不同的工作表,那么您可以编码:
Set XlSheet = ActiveSheet
With XlSheet
.Cells(1, 15) = "Date"
lRow = .Cells(.Rows.count, 1).End(xlUp).row
Set rng = .Range(.Cells(2, 15), .Cells(lRow, 5))
End With
rng.Value = Date