Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Clearing Form

Hi, I would to clear an Excel form (Text boxes and check boxes) after the
user has clicked the Submit button.
Can any one tell me the code to do this please?

TIA,
PE1


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Clearing Form

Hi Pe1

one way among several:

Private Sub CommandButton1_Click()
Dim C As MSForms.Control
For Each C In Me.Controls
Select Case TypeName(C)
Case "TextBox"
C.Text = ""
Case "ComboBox", "ListBox"
C.ListIndex = -1
Case "CheckBox", "OptionButton"
C.Value = False
Case Else
End Select
Next
End Sub

HTH. Best wishes Harald

"PEno1" skrev i melding
...
Hi, I would to clear an Excel form (Text boxes and check boxes) after the
user has clicked the Submit button.
Can any one tell me the code to do this please?

TIA,
PE1




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Clearing Form

presuming your form is 'userform1' i *think* this should work...

sub ClearAll()
on error resume next
for each control in userform1.controls
control.visible=false
control.value=false
control.text=""
next control
end sub

the 'on error...' avoids problems of controls not having some properties,
but also means that other problems might go un-noticed - maybe someone else
has a better solution?

hth

tim

"PEno1" wrote in message
...
Hi, I would to clear an Excel form (Text boxes and check boxes) after the
user has clicked the Submit button.
Can any one tell me the code to do this please?

TIA,
PE1




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing #N/A's in one go? Lee Harris Excel Worksheet Functions 5 November 22nd 05 06:52 PM
Clearing #VALUE skateblade Excel Worksheet Functions 3 October 15th 05 10:34 PM
what is clearing an assumption? Bascious Excel Worksheet Functions 0 November 12th 04 01:52 PM
Clearing list from all form commandboxes josh ashcraft Excel Programming 2 August 19th 03 12:58 PM


All times are GMT +1. The time now is 06:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"