我知道我们可以使用以下代码获取包含数据的最后一行:
LastRow = .Range(“D”&.Rows.Count).End(xlUp).Row
但是我在使用数据获取最后一列时遇到了麻烦 . 这是我尝试过的,你可以从它没有经过的图像中看到
Set ws = ThisWorkbook.ActiveSheet
With ws
Header = 5
LastRow = .Range("D" & .Rows.Count).End(xlUp).Row
LastCol = .Range(5 & .ColumnCount).End(xlLeft).Column
With .Range("A" & Header & LastCol & LastRow)
.Interior.ColorIndex = 16
End With
End With
能告诉我锄头我可以解决这个问题吗?谢谢
1 回答
试试这个,因为我已经评论过:
我不确定它是
xlLeft
还是xlToLeft
. 亲自尝试一下 .使用它来为整个范围着色:
这个颜色
A5
到你的最后一列和一行 .