我有一个简单的for-next来填充用户表单上的一些标签,但无法弄清楚为什么一直得到"错误1004"当我输入Contr.Caption时,.Caption函数丢失了?
Dim Control_Name As String
Dim DSlot As Long
Dim DLName As Long
Dim Contr As Control
With Worksheets("apartments").Range("depositslot")
DSlot = .Find("Slot").Row + 1
DLName = .Find("Last").Column
End With
For Each Contr In Layout.Controls
If TypeName(Contr) = "Label" Then
Control_Name = Mid(Contr.Name, 1, 6)
If Control_Name = "LBName" Then
Contr.Caption = Worksheets("apartments").Range(DSlot, DLName).Value
DSlot = DSlot + 1
End If
End If
Next
Run Code Online (Sandbox Code Playgroud)