Compile Error: Method or data member not found error

Apr 7, 2015
Reaction score
I'm trying to make a userform and I'm not sure what went wrong with the command button code, could someone just look at it and tell me what to change, Thank you :)

Private Sub commandbutton_add_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_title.Value
ws.Cells(iRow, 2).Value = Me.textbox_name.Value
ws.Cells(iRow, 3).Value = Me.textbox_surname.Value
ws.Cells(iRow, 4).Value = Me.textbox_address.Value
ws.Cells(iRow, 5).Value = Me.textbox_party.Value
ws.Cells(iRow, 6).Value = Me.TextBox_number.Value
ws.Cells(iRow, 7).Value = Me.textbox_date.Value

MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_title.Value = ""
Me.textbox_name.Value = ""
Me.textbox_surname.Value = ""
Me.textbox_address.Value = ""
Me.textbox_party.Value = ""
Me.TextBox_number.Value = ""
Me.textbox_date.Value = ""

End Sub

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