Hi all,
I'm working on a userform. When changing a certain optionbutton, the userform should reset all pages of a multipage.
I tried reset/ multipage.pages().controls.clear/...
nothing seems to work. Who can help me with the code please?
Thanks!
Hi all,
I'm working on a userform. When changing a certain optionbutton, the userform should reset all pages of a multipage.
I tried reset/ multipage.pages().controls.clear/...
nothing seems to work. Who can help me with the code please?
Thanks!
Not sure about what 'reset' exactly means since it's not a VBA method as far as I can see
UserForm1 has MultiPage1 on it with Page1..Page5
HTH
Option Explicit Sub drv() Load UserForm1 Dim i As Long For i = 0 To UserForm1.MultiPage1.Pages.Count - 1 Select Case i Case 0 MsgBox "Resetting " & UserForm1.MultiPage1.Pages(i).Caption Case 1 MsgBox "Resetting " & UserForm1.MultiPage1.Pages(i).Caption Case 2 MsgBox "Resetting " & UserForm1.MultiPage1.Pages(i).Caption 'etc. End Select Next i UserForm1.Show End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Thanks for your reply Paul!
I want to clear all pages on the multipage (textboxes, optionbuttons and checkboxes).
I have a button, when you click the button, the vba should erase the multipage.
Maybe this then, but .Clear only works for controls added at run time
Otherwise you'd probably have to loop the Pages and then loop the Controls with .Delete
PS -- Not testedOption Explicit Sub drv() Load UserForm1 Dim i As Long For i = 0 To UserForm1.MultiPage1.Pages.Count - 1 UserForm1.MultiPage1.Pages(i).Clear Next I UserForm1.Show End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Are you looking for something like
Dim onePage As MSForms.Page Dim oneControl As MSForms.Control, i As Long For Each onePage In MultiPage1.Pages For Each oneControl In onePage.Controls Select Case TypeName(oneControl) Case "CheckBox", "OptionButton" oneControl.Value = False Case "TextBox", "RefEdit" oneControl.Text = vbNullString Case "ComboBox", "ListBox" If oneControl.MultiSelect <> fmMultiSelectSingle Then With oneControl For i = 0 To .ListCount - 1 .Selected(i) = False Next i End With Else oneControl.ListIndex = -1 End If End Select End Select Next oneControl Next onePage