I have a VBA code for finding type of the Userform controls and add comments to some of the cells in my excel sheet. These Useform controls are dynamic. I meant, This controls like Textbox, label, etc are inserted by using another macro. It works fine. I use something like this format to add those controls:: set Label1i = UserForm2.Controls.Add("Forms.Label.1", "Test" & labelCounter, True)
. When I call below sub from the commandbutton on same userform. I am getting "Runtime 438 error: Object doesn't support this property or method"
Below code was running successfully. However, when I add one more manual "Textbox" to this program, it showed this error.
Private Sub CommandButton1_Click()
Dim cCont As Control
Dim Commnts As String
Commnts = ""
For Each cCont In Me.Controls
If TypeName(cCont) = "TextBox" And cCont <> "" Then
Commnts = cCont
Sheet1.Range(cCont.ControlTipText).AddComment Commnts
End If
Next cCont
If Commnts <> "" Then
Unload UserForm2
MsgBox ("Comments updated")
Call Graphic16_Click
Else
MsgBox ("Nothing to update")
End If
End Sub
Could someone please help me on this.