View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Matthew Herbert[_3_] Matthew Herbert[_3_] is offline
external usenet poster
 
Posts: 149
Default Editing controls on a userform en masse

Shane,

The code below is untested and will need to be altered for your specific
case, but it should work. The code assumes that the MultiPage control on the
form is named "frmPgs".

Best,

Matthew Herbert

Dim Pg As Page
Dim Ctrl As MSForms.Control
'check "Tools | Reference | Microsoft Forms 2.0 Object Library" to
' use MSForms; otherwise, simply use Dim Ctrl As Control

'loop through each page in the Pages collection of the form
For Each Pg In frmPgs.Pages

'loop through each control on the page
For Each Ctrl In Pg.Controls

'get the desired control type
If TypeOf Ctrl Is MSForms.TextBox Then

'set the control value
Ctrl.Value = ""
End If
Next Ctrl
Next Pg

"Shane" wrote:

I have a userform that has multiple pages, each page has various controls
(TextBox, ComboBox, CheckBox). Is there code that I can use to clear all of
the values in the userform?

I was thinking "For Each", but I am new to code and keep getting lost...

Any help is appreciated!