批量修改控件属性(VBA)
我在EXCEL-sheet2中设置了18个标签控件,名字分别为n1n2n3n4.....n18现在我想用for语句将它们前景色改为白色也就是打印的时候不会打印出来我用如下...
我在EXCEL-sheet2中设置了18个标签控件,名字分别为n1 n2 n3 n4.....n18现在我想用for语句将它们前景色改为白色也就是打印的时候不会打印出来我用如下语句可是不知道错在哪里,还望指点。谢谢!
Private Sub CommandButton7_Click()
Dim dx As Object
For i = 1 To 18
dx = "n" & i
Sheets("sheet2").dx.ForeColor = &HFFFFFF
Next i
UserForm4.Show
End Sub 展开
Private Sub CommandButton7_Click()
Dim dx As Object
For i = 1 To 18
dx = "n" & i
Sheets("sheet2").dx.ForeColor = &HFFFFFF
Next i
UserForm4.Show
End Sub 展开
2个回答
展开全部
1.dx本身不是字符串
2."n" & i 这个表达式有问题,至少应该是"n" + cstr(i),当然,即使改成这样也没用
3.最直接的办法就是
n1.forecolor= &HFFFFFF
n2.forecolor= &HFFFFFF
n3.forecolor= &HFFFFFF
n4.forecolor= &HFFFFFF
n5.forecolor= &HFFFFFF
n6.forecolor= &HFFFFFF
n7.forecolor= &HFFFFFF
n8.forecolor= &HFFFFFF
n9.forecolor= &HFFFFFF
n10.forecolor= &HFFFFFF
n11.forecolor= &HFFFFFF
n12.forecolor= &HFFFFFF
n13.forecolor= &HFFFFFF
n14.forecolor= &HFFFFFF
n15.forecolor= &HFFFFFF
n16.forecolor= &HFFFFFF
n17.forecolor= &HFFFFFF
n18.forecolor= &HFFFFFF
2."n" & i 这个表达式有问题,至少应该是"n" + cstr(i),当然,即使改成这样也没用
3.最直接的办法就是
n1.forecolor= &HFFFFFF
n2.forecolor= &HFFFFFF
n3.forecolor= &HFFFFFF
n4.forecolor= &HFFFFFF
n5.forecolor= &HFFFFFF
n6.forecolor= &HFFFFFF
n7.forecolor= &HFFFFFF
n8.forecolor= &HFFFFFF
n9.forecolor= &HFFFFFF
n10.forecolor= &HFFFFFF
n11.forecolor= &HFFFFFF
n12.forecolor= &HFFFFFF
n13.forecolor= &HFFFFFF
n14.forecolor= &HFFFFFF
n15.forecolor= &HFFFFFF
n16.forecolor= &HFFFFFF
n17.forecolor= &HFFFFFF
n18.forecolor= &HFFFFFF
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询