VBA: Populate Userform checkboxes based on Cells Values

iDeals

Board Regular
Joined
Oct 22, 2008
Messages
236
okay, so I constructed a loop to populate a range of cells based on the value of checkboxes in a userform.

Now I'm trying to do the reverse.

have the userform on activation mark the checkboxes according to the range it filled prior.

Here is the working loop from form to worksheet:

Code:
Dim k As IntegerFor k = 1 To 3
editrow = Application.Match(Sheets("Sheet2").Range("H1"), Sheets("Sheet2").Range("A:A"), 0)
nextc = Sheets("Sheet2").Cells(editrow, Columns.Count).End(xlToLeft).Column + 1


If UserForm1.Controls("Checkbox" & k).Value = False Then Sheets("sheet2").Cells(editrow, nextc).Value = UserForm1.Controls("Checkbox" & k).Name


Next k

end sub


Now I've tried numerous strategies to get the reverse to work but so far no dice... here is my current attempt:

Code:
Private Sub UserForm_Activate()Dim counter As Integer


ComboBox1.Value = Sheets("Sheet2").Range("H1")
editrow = Application.Match(Sheets("Sheet2").Range("H1"), Sheets("Sheet2").Range("A:A"), 0)
nextc = Sheets("Sheet2").Cells(editrow, Columns.Count).End(xlToLeft).Column + 1




    
    For counter = 1 To 3
        Set curCell = Sheets("Sheet2").Cells(editrow, counter + 1)
            If curCell = "Checkbox1" Then
                    CheckBox1.Value = False
            ElseIf curCell = "Checkbox2" Then
                    CheckBox2.Value = False
            ElseIf curCell = "Checkbox3" Then
                    CheckBox3.Value = False
            End If
    Next counter
    
On Error GoTo getout


getout:
End Sub

I initially was trying to do a case statement, but couldn't get it to loop so I had to change it to "if's"


any help would be greatly appreciated!
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top