excel vba userform clear details

G

Guest

hi,
im creating a userform and im wanting to input details ie name etc into
excel cells...i have added a cmd button to exit the form and im wanting a cmd
button to input the details to the cell range BUT continue to keep the form
open to add more names to my list. i cant figure out what code to use to
delete the current information in the form.

*** i dont want to clr the info in excel worksheet just the info in the
userform to add new data

i have so far........
Private Sub cmdInputData_Click()
Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Range("A1").Select
Selection.Value = txtName
Range("A1").Select
Selection.End(xlDown).Offset(0, 1).Range("A1").Select
Selection.Value = txtAmount
End Sub

thanks for your time...
 
J

John

Hello Kelzina,

To keep to form open change the ShowModal property to False.

Then try the code below and remember you'll need to add a Close button (or
some other method) to allow the user to actually close the form.

Private Sub cmdInputData_Click()
Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Range("A1").Select
Selection.Value = txtName
Range("A1").Select
Selection.End(xlDown).Offset(0, 1).Range("A1").Select
Selection.Value = txtAmount
Call ClearFormValues
End Sub

Private Sub ClearFormValues()
With Me
.txtName = ""
.txtAmount = ""
End With
End Sub

Best regards

John
 
G

Guest

thank you so much john, really appreciated
:)
kelz
--
"The difference between Possible and Impossible is the measure of ones will"


John said:
Hello Kelzina,

To keep to form open change the ShowModal property to False.

Then try the code below and remember you'll need to add a Close button (or
some other method) to allow the user to actually close the form.

Private Sub cmdInputData_Click()
Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Range("A1").Select
Selection.Value = txtName
Range("A1").Select
Selection.End(xlDown).Offset(0, 1).Range("A1").Select
Selection.Value = txtAmount
Call ClearFormValues
End Sub

Private Sub ClearFormValues()
With Me
.txtName = ""
.txtAmount = ""
End With
End Sub

Best regards

John
 

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

Top