|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位好老师好:
以下代码烦请帮忙看下能否改成 循环语句,以缩减代码量,谢谢。
If ListBox1.Column(3) <> "" And a = 1 Then deng1.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 2 Then deng2.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 3 Then deng3.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 4 Then deng4.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 5 Then deng5.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 6 Then deng6.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 7 Then deng7.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 8 Then deng8.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 9 Then deng9.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 10 Then deng10.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 11 Then deng11.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 12 Then deng12.BackColor = &HFF&
If ListBox1.Column(3) <> "" And a = 13 Then deng13.BackColor = &HFF&
If ListBox1.Column(3) = "" And a = 1 Then
deng1.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 2 Then
deng2.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 3 Then
deng3.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 4 Then
deng4.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 5 Then
deng5.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 6 Then
deng6.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 7 Then
deng7.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 8 Then
deng8.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 9 Then
deng9.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 10 Then
deng10.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 11 Then
deng11.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 12 Then
deng12.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
ElseIf ListBox1.Column(3) = "" And a = 13 Then
deng13.BackColor = &HC000&
Label15.ForeColor = &HC000&
tt = "可用"
Else
Label15.ForeColor = &HFF&
tt = "不可用"
End If
|
|