Hi everyone,
I've got to run the same lot of code 3 times over. In order to achieve this I'm using a "For i = 1 to 3" method. Here is an extract of my code:
Private Sub UserForm_Activate()
Dim Cntrl As MSForms.Control
For i = 1 To 3
' OP Times
UseFrame = "I_D" & i & "_OT_F"
For Each Cntrl In Me.Controls(UseFrame)
If Cntrl.Name Like "*_TH" Then Cntrl.BackColor = RGB(33, 89, 103)
If Cntrl.Name Like "*_TS" Then Cntrl.BackColor = RGB(218, 238, 243)
If Cntrl.Name Like "*_TC" Then Cntrl.BackColor = RGB(238, 236, 225)
Next Cntrl
Next i
End Sub
Effectively I want to use the "UseFrame" string as the control name to use. It will update each time until it reaches 3. For some reason I'm getting an error on the "For Each Cntrl in Me.Controls(UseFrame)" line. Any ideas why?
Error is: "Run-time error '438': Object doesn't support this property or method".
I'm sure it's an easy fix but can't figure it out.
Many thanks,
Daniel
Moved from: (Office /Excel /Windows 10 /Office 2016 )