Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CheckBoxes on MultiPage
Initially I was setting the values of a group of CheckBoxes on a UserForm
via the following code (and it worked well): Private Sub Binary2CB() cbResult = "0011001101" ' (for test purposes) Dim x As Integer For x = 1 To 10 If Mid(cbResult, x, 1) = 1 Then Userform1.Controls("CheckBox" & x).Value = True End If Next x End Sub I've since moved the CheckBoxes onto a Mulitpage control on the same UserForm. How can I modify the code above to make this work? (I've tried a number of different manipulations but can't seem to find the right combination). Thanks, John |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
CheckBoxes on MultiPage
Have you tried
Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True -- HTH RP (remove nothere from the email address if mailing direct) "John Wilson" wrote in message ... Initially I was setting the values of a group of CheckBoxes on a UserForm via the following code (and it worked well): Private Sub Binary2CB() cbResult = "0011001101" ' (for test purposes) Dim x As Integer For x = 1 To 10 If Mid(cbResult, x, 1) = 1 Then Userform1.Controls("CheckBox" & x).Value = True End If Next x End Sub I've since moved the CheckBoxes onto a Mulitpage control on the same UserForm. How can I modify the code above to make this work? (I've tried a number of different manipulations but can't seem to find the right combination). Thanks, John |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CheckBoxes on MultiPage
Bob,
No, I hadn't tried that. Your suggestion didn't work until I removed the UserForm1 reference but you did get me started in the right direction. The following: MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Did work though. There were actually 25 CheckBoxes across the 3 pages on that MultiPage so my final code ended up looking like this: Private Sub Binary2CB() cbResult = "0100000000001110000000010" ' (For test purposes) Dim x As Integer For x = 1 To 25 If Mid(cbResult, x, 1) = 1 Then If x < 12 Then MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Else If x 21 Then MultiPage1.Pages(2).Controls("CheckBox" & x).Value = True Else MultiPage1.Pages(1).Controls("CheckBox" & x).Value = True End If End If End If Next x End Sub Thank you very much for your help, John "Bob Phillips" wrote in message ... Have you tried Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True -- HTH RP (remove nothere from the email address if mailing direct) "John Wilson" wrote in message ... Initially I was setting the values of a group of CheckBoxes on a UserForm via the following code (and it worked well): Private Sub Binary2CB() cbResult = "0011001101" ' (for test purposes) Dim x As Integer For x = 1 To 10 If Mid(cbResult, x, 1) = 1 Then Userform1.Controls("CheckBox" & x).Value = True End If Next x End Sub I've since moved the CheckBoxes onto a Mulitpage control on the same UserForm. How can I modify the code above to make this work? (I've tried a number of different manipulations but can't seem to find the right combination). Thanks, John |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
CheckBoxes on MultiPage
John
Did you change the name of your userform? I didn't need to preface the control reference with the mulitpage, so it sounds like you may have two userforms. You didn't say what error you were getting, if any, so it's hard to say if that's it. If the code is in the userform's code module, you should be able to use Me.Controls("CheckBox" & x).Value Me is a keyword that refers to the class it's contained in, in this case the userform. If you ever happen to change the name of the userform, Me will still work. -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com John Wilson wrote: Bob, No, I hadn't tried that. Your suggestion didn't work until I removed the UserForm1 reference but you did get me started in the right direction. The following: MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Did work though. There were actually 25 CheckBoxes across the 3 pages on that MultiPage so my final code ended up looking like this: Private Sub Binary2CB() cbResult = "0100000000001110000000010" ' (For test purposes) Dim x As Integer For x = 1 To 25 If Mid(cbResult, x, 1) = 1 Then If x < 12 Then MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Else If x 21 Then MultiPage1.Pages(2).Controls("CheckBox" & x).Value = True Else MultiPage1.Pages(1).Controls("CheckBox" & x).Value = True End If End If End If Next x End Sub Thank you very much for your help, John "Bob Phillips" wrote in message ... Have you tried Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True -- HTH RP (remove nothere from the email address if mailing direct) "John Wilson" wrote in message ... Initially I was setting the values of a group of CheckBoxes on a UserForm via the following code (and it worked well): Private Sub Binary2CB() cbResult = "0011001101" ' (for test purposes) Dim x As Integer For x = 1 To 10 If Mid(cbResult, x, 1) = 1 Then Userform1.Controls("CheckBox" & x).Value = True End If Next x End Sub I've since moved the CheckBoxes onto a Mulitpage control on the same UserForm. How can I modify the code above to make this work? (I've tried a number of different manipulations but can't seem to find the right combination). Thanks, John |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
CheckBoxes on MultiPage
Dick,
Yes, I did change the name of the UserForm to "OCMC". Bob gave me this: Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True which I changed to this: OCMC.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True and it didn't work. The error that the above gives is "Object doesn't support this property or method" The following did work though: MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True I tried this and it also worked: Me.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True All the code is in the UserForm module. Looking at it again, it really doesn't make sense why if "Me" works and no preface works, why wouldn't "OCMC" (the actual name of the UserForm) wouldn't work. Again, Bob did steer me in the right direction ("Pages(0)" was the critical part that I was missing) and I did get it to work. Thanks, John "Dick Kusleika" wrote in message ... John Did you change the name of your userform? I didn't need to preface the control reference with the mulitpage, so it sounds like you may have two userforms. You didn't say what error you were getting, if any, so it's hard to say if that's it. If the code is in the userform's code module, you should be able to use Me.Controls("CheckBox" & x).Value Me is a keyword that refers to the class it's contained in, in this case the userform. If you ever happen to change the name of the userform, Me will still work. -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com John Wilson wrote: Bob, No, I hadn't tried that. Your suggestion didn't work until I removed the UserForm1 reference but you did get me started in the right direction. The following: MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Did work though. There were actually 25 CheckBoxes across the 3 pages on that MultiPage so my final code ended up looking like this: Private Sub Binary2CB() cbResult = "0100000000001110000000010" ' (For test purposes) Dim x As Integer For x = 1 To 25 If Mid(cbResult, x, 1) = 1 Then If x < 12 Then MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True Else If x 21 Then MultiPage1.Pages(2).Controls("CheckBox" & x).Value = True Else MultiPage1.Pages(1).Controls("CheckBox" & x).Value = True End If End If End If Next x End Sub Thank you very much for your help, John "Bob Phillips" wrote in message ... Have you tried Userform1.MultiPage1.Pages(0).Controls("CheckBox" & x).Value = True -- HTH RP (remove nothere from the email address if mailing direct) "John Wilson" wrote in message ... Initially I was setting the values of a group of CheckBoxes on a UserForm via the following code (and it worked well): Private Sub Binary2CB() cbResult = "0011001101" ' (for test purposes) Dim x As Integer For x = 1 To 10 If Mid(cbResult, x, 1) = 1 Then Userform1.Controls("CheckBox" & x).Value = True End If Next x End Sub I've since moved the CheckBoxes onto a Mulitpage control on the same UserForm. How can I modify the code above to make this work? (I've tried a number of different manipulations but can't seem to find the right combination). Thanks, John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MultiPage tab? | Excel Discussion (Misc queries) | |||
MultiPage | Excel Discussion (Misc queries) | |||
How do I use multipage | Excel Discussion (Misc queries) | |||
vba - using multipage | Excel Programming | |||
MultiPage | Excel Programming |