Userforms submit button to clear after it enters data?

C

carlaruge

I have User form that has a submit button that when selected enters dat
to the spreadsheet, but doesn't clear the form unless you click on th
clear form button. Is there anyway to write that it will also clea
the form after it has entered all of the data into the worksheet?

Here is the VB for the button...

Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Sign In").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtName.Value
ActiveCell.Offset(0, 1) = txtAddress.Value
ActiveCell.Offset(0, 2) = txtCity.Value
ActiveCell.Offset(0, 3) = txtState.Value
ActiveCell.Offset(0, 4) = txtZip.Value
ActiveCell.Offset(0, 6) = txtdegree1.Value
ActiveCell.Offset(0, 7) = txtdegree2.Value
ActiveCell.Offset(0, 8) = txtCert1.Value
ActiveCell.Offset(0, 9) = txtCert1.Value
If optElementary = True Then
ActiveCell.Offset(0, 5).Value = "Elementary"
ElseIf optMiddle = True Then
ActiveCell.Offset(0, 5).Value = "Middle School"
Else
ActiveCell.Offset(0, 5).Value = "Secondary"
End If

Thanks
Carl
 
T

Tom Ogilvy

Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Sign In").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtName.Value
ActiveCell.Offset(0, 1) = txtAddress.Value
ActiveCell.Offset(0, 2) = txtCity.Value
ActiveCell.Offset(0, 3) = txtState.Value
ActiveCell.Offset(0, 4) = txtZip.Value
ActiveCell.Offset(0, 6) = txtdegree1.Value
ActiveCell.Offset(0, 7) = txtdegree2.Value
ActiveCell.Offset(0, 8) = txtCert1.Value
ActiveCell.Offset(0, 9) = txtCert1.Value
txtAddress.Value
txtCity.Value = ""
txtState.Value = ""
txtZip.Value = ""
txtdegree1.Value = ""
txtdegree2.Value = ""
txtCert1.Value = ""
txtCert1.Value = ""
If optElementary = True Then
ActiveCell.Offset(0, 5).Value = "Elementary"
ElseIf optMiddle = True Then
ActiveCell.Offset(0, 5).Value = "Middle School"
Else
ActiveCell.Offset(0, 5).Value = "Secondary"
End If
End Sub
 
C

carlaruge

I used this to initilize the form also, I thought I tried this but must
have had it in the wrong place.

Thanks for your help!
 

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