Form not working please help

PCRIDE

Well-known Member
Joined
Jan 20, 2008
Messages
902
I have this code on a Submit button and the button is named SubmitButton3, after I press Submit the form disappears and no data is logged in my columns. Any Ideas?


Private Sub SubmitButton3_Click()
Dim NextEmptyRow As Integer
NextEmptyRow = Range("B10005").End(xlUp).Row + 1
Worksheets("Register").Cells(NextEmptyRow, 2).Value = "Survey"
Worksheets("Register").Cells(NextEmptyRow, 3).Value = SurveyForm.Date.Text
Worksheets("Register").Cells(NextEmptyRow, 4).Value = SurveyForm.Name.Text
Worksheets("Register").Cells(NextEmptyRow, 5).Value = SurveyForm.Time3.Text
SurveyForm.Hide
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
My first thoughts are that "Date" is not a legal object name and "Name" is a confusing object name. Changing those might let the code do its thing.
 
Upvote 0
PCRIDE, please use the CODE tags in the future when posting code. It makes code easier to read.

Anyway, regarding the issue..

When you define the variable NextEmptyRow, you're not assigning it to a specific sheet (like you're doing with every row below it). Try changing
Code:
Private Sub SubmitButton3_Click()
Dim NextEmptyRow As Integer
With Sheets("Register")
    NextEmptyRow = .Range("B10005").End(xlUp).Row + 1
    .Cells(NextEmptyRow, 2).Value = "Survey"
    .Cells(NextEmptyRow, 3).Value = SurveyForm.Date.Text
    .Cells(NextEmptyRow, 4).Value = SurveyForm.Name.Text
    .Cells(NextEmptyRow, 5).Value = SurveyForm.Time3.Text
End With
SurveyForm.Hide
End Sub<!-- / message -->
Also, check your names for "Date" and "Name". Those are reserved words in VBA.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top