我有一个表,该表位于电子表格上的某个位置,例如b3:f15,并且在该表附近没有任何内容(空单元格),我试图选择该表并为其着色。不知何故我的代码不起作用,我只是找不到逻辑错误
Sub colorize_table()
Dim temp As Range
Set temp = Application.InputBox(prompt:="Please choose cell", Type:=8)
Dim i As Integer, k As Integer
Dim r As Integer, p As Integer
i = temp.Row
k = temp.Column
r = temp.Row
p = temp.Column
While temp(i, k) <> ""
While temp(i, k) <> ""
i = i - 1
Wend
k = k - 1
Wend
While temp(r, p) <> ""
While temp(r, p) <> ""
r = r + 1
Wend
p = p + 1
Wend
Set temp = Range(Cells(i-1, k-1).Address, Cells(r+1, p+1).Address)
temp.Interior.ColorIndex = 36
End Sub
有什么建议?提前致谢
使用:
temp.CurrentRegion.Interior.ColorIndex = 36
而不是循环。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句