Hi guys I've been scouring the internet for a solution to this problem but I can't seem to find it anywhere.
Basically I'm creating a worksheet which is going to be a generic sheet to fit all of the work that we do, in order to do this I have a userform with a series of checkboxes on it to generate pages and show specific data on those pages for what is and isn't selected from these checkboxes.
The following code takes all of the data from my checkboxes and stores their values onto a worksheet:
Dim contr As Control
Dim x As Integer
x = 3
For Each contr In rollercoastersetup.Controls
If TypeName(contr) = "CheckBox" Then
Sheets("ChkBox Results").Cells(x, "B").Value = contr.Name
Sheets("ChkBox Results").Cells(x, "C").Value = contr.Value
x = x + 1
End If
If TypeName(contr) = "TextBox" Then
Sheets("ChkBox Results").Cells(x, "B").Value = contr.Name
Sheets("ChkBox Results").Cells(x, "C").Value = contr.Value
x = x + 1
End If
Next
This code generates the list of all the controls on the userform in one column (starting from B3) and all the values of those controls in the next column (starting at C3) as below:
Check Box Name |
True/False/Value |
oproomnopanel |
TRUE |
oproomwithpanel |
FALSE |
station |
FALSE |
What I'd like to be able to do with that info is to then be able to repopulate the userform when it is re opened so that if somebody needs to add or remove something it can be done in this way rather than restarting the whole worksheet. The code I have is as follows but the syntax isn't even close to being right so any help would be greatly appreciated!
Private Sub UserForm_Activate()
Dim controlname As Integer
For controlname = 3 To 200
Me.Controls(Sheets("ChkBox Results").Cells(controlname, "B").Value).Value = Sheets("ChkBox Results").Cells(controlname, "C").Value
Next
End Sub
Thanks for your help
Tom
Bookmarks