更新时间:2022-06-19 23:42:45
在工作表中,标签是Shape
对象,因此可以使用Shapes
集合:
In a Worksheet, a Label is a Shape
Object, so you can use the Shapes
collection:
Dim i As Integer
Dim shpLabel As Shape
For i = 1 To 81
Set shpLabel = Sheet1.Shapes("labelnum" & i)
If shpLabel.Caption = Label1.Caption Then
shpLabel.BackColor = Label1.BackColor
End If
Set shpLabel = Nothing
Next i
在用户窗体中,标签是Control
对象,因此可以使用Controls
集合:
In a UserForm, a Label is a Control
Object, so you can use the Controls
collection:
Dim i As Integer
Dim ctrlLabel As Control
For i = 1 To 81
Set ctrlLabel = Me.Controls("labelnum" & i)
If ctrlLabel.Caption = Label1.Caption Then
ctrlLabel.BackColor = Label1.BackColor
End If
Set ctrlLabel = Nothing
Next i