excel vba怎么选择整列和整行

如题。用宏,并且需要用 循环语句,for i=1 to 100 来分别选取第1列到100列改变该列的填充色,第二个表要用for i=1 to 100 选择第一行到100行改变指定行的填充色,仅仅举个列子,要通用方法,别搞特例,谢谢。

第1个回答  2010-07-02
for i=1 to 100
Columns(i).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
next i

for i=1 to 100
rows(i).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
next i本回答被提问者采纳
第2个回答  2010-07-02
Sub 填充()
For i = 1 To 100
Sheets(1).Cells(1, i).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.Color = 255
End With
Sheets(1).Cells(i, 1).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.Color = 1
End With
Next
End Sub
相似回答