20 To 89 Step 3(T列到CK列)
给代码加表名(因安键在别表)
以T最后显示为起点,到第10(这里我可以修改为哪一行)行结束
你选菜单开始录制宏,设置一个单元格的颜色为自动,停止录制,查看这个宏的代码:
Sub 宏1()现在你就明白了,设置单元格颜色为自动的语句应该是:
Selection.Font.ColorIndex = xlAutomatic
在你的代码里面可以这样写:
for i=20 to 89 step 3With Sheet2用这样的表名?
Sub 宏1()
With Sheet2.Select
for i=20 to 89 step 3
for j=4 to 10
cells(i,j).Font.ColorIndex = xlAutomatic
next j
next i
End With
End Sub
你这个with是什么意思?
我的语句:
cells(i,j).Font.ColorIndex = xlAutomatic
表示修改代码运行时会显示的这个表,如果需要指定sheet2代码应该这样:
sheet2.cells(i,j).Font.ColorIndex = xlAutomatic
Sub 宏1()
For i = 20 To 89 Step 3
For j = 1483 To 2000
Sheet2.Cells(i, j).Font.ColorIndex = xlAutomatic
Next j
Next i
End Sub
是这样吗?
Sheet2.Cells(i, j).Font.ColorIndex = xlAutomatic这句提示
提示的什么?
我粘贴了你的语句,在我的电脑上执行没有任何错误,完全正确。我第一次给你的代码没有Sheet2,你自己偏要加上的,如果你只有一个工作表,那么肯定会错,因为第一个工作表的名称应该是Sheet1。
我工作表有多个,所以Sheet2不错,
cells(i,j).Font.ColorIndex = xlAutomatic用这个也是一样的提示
你的i,j弄反了,没有2000列,cells出界。
追问For j = 1483 To 2000这个不 是行的范围?哪行是如何控制它的范围
还有就是,我的单元格里的内容为其它颜色,哪为什么还是原来的原色,没有被修改为默认的颜色(自动的黑色)呢?
cells(行,列),行的范围1~65536,列的范围1~256