
excel vba怎么选择整列和整行
如题。用宏,并且需要用循环语句,fori=1to100来分别选取第1列到100列改变该列的填充色,第二个表要用fori=1to100选择第一行到100行改变指定行的填充色...
如题。用宏,并且需要用 循环语句,for i=1 to 100 来分别选取第1列到100列改变该列的填充色,第二个表要用for i=1 to 100 选择第一行到100行改变指定行的填充色,仅仅举个列子,要通用方法,别搞特例,谢谢。
展开
2个回答
展开全部
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询