I thought I'd find this by searching the forum, but no luck. In my userform, I import a bunch of data that may or may not be valid. I use checkboxes so the user can click if the data is valid, all the controls become unlocked and ungreyed, then edit it as necessary. But I really dont want to beleaguer my module with 20 of these checkbox macros. Isnt there a way to apply one macro to all checkboxes in a userform? Thanks. -Luke
HTML Code:Private Sub check1_Click() Dim ctrl As MSForms.Control 'activity is not valid so is greyed out If check1 = False Then For Each ctrl In data.Frame1.Controls If TypeName(ctrl) = "Label" Then ctrl.ForeColor = RGB(150, 150, 150) ElseIf TypeName(ctrl) = "CheckBox" Then ctrl.Enabled = False Else ctrl.Locked = True ctrl.BackColor = &H80000004 End If Next ctrl End If 'activity is valid so can be edited If check1 = True Then For Each ctrl In data.Frame1.Controls If TypeName(ctrl) = "Label" Then ctrl.ForeColor = RGB(0, 0, 0) ElseIf TypeName(ctrl) = "CheckBox" Then ctrl.Enabled = True Else ctrl.Locked = False ctrl.BackColor = &H80000005 End If Next ctrl End If End Sub
Bookmarks