Clearing user forms

  • Thread starter Thread starter anthony slater
  • Start date Start date
A

anthony slater

I've made a simple user form consisting of 3 input text
boxes. After inputting values, a command button is clicked
and the user form closes and populates 3 cells in a
worksheet with the values.

I have another command button (from the forms menu) on the
worksheet that will clear the inputted data and re-load
the user form ready for another input.

At the moment the user form reloads but the previous
values are still there. The following code is used: -

Private Sub commandbutton32()
Sub button32_Click()
Range("a1").ClearContents
Range("a2").ClearContents
Range("f3").ClearContents
Range("f5").ClearContents
Range("f9").ClearContents
UserForm1.Show

End Sub

How can I get the user userform to reload with blank text
boxes?
 
anthony, something like this

UserForm1.TextBox1.Value = ""
UserForm1.TextBox2.Value = ""
UserForm1.TextBox3.Value = ""
Unload UserForm1
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
 
When you close the userform, how are you doing it? If you us
UserForm1.Hide, then that's the problem. You would probably want t
use Unload UserForm1.

If that's not the problem, is there anything in the Userform_Activat
or UserForm_Initialize event that pre-populates the text boxes wit
values from the sheet? If so, you would want to stop doing that...
 
When you close the userform unload it rather than hide it

Unload Userform1

rather than

Userform1.Hide
 
I tried the code given below but when the userform is reloaded, the old
values are still there.

Do I put this code in the module or in the userform section?

Sorry about this but fairly new to VB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top