我试图作出这样的选择的颜色一组5个细胞 的所以基本上是去宏: 透明,黄色,蓝色,清澈,黄,蓝,...Excel范围选择问题
Sub ColorBanding()
Dim num As Integer
For i = 2 To 50
Dim range As String
range("A" + Str(i) + ":E" + Str(i)).Select
If i Mod 3 = 0 Then
Cells(1, 1).Select
' Yellow
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ElseIf i Mod 3 = 2 Then
' Blue
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
End If
Next i
End Sub
我在使用这条线的麻烦: “范围(” A “+ STR(ⅰ)+ ”:E“ + STR(i))的选择。” 上评价
实施例,对于i = 2: 输出: “A 2:电子2” 应该是: “A2:E2”
我得到的技术错误是: “预计阵列”
有没有更好的方法来做到这一点? 有没有办法让这种方式正常工作?
对不起,这个数字是从我打算用while循环进行手动递增时剩下的。自从我找到For循环语法。对不起,它可能造成的任何混淆。 – Zigu 2011-04-23 06:56:48