Hi Guys
I am new here and really struggling with VBA, I am trying to get a simple form on excel
Form.png like this
I keep getting Syntax error when i click the add data button, Here is the code that is on that button
Private Sub AddDetails_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.TextBox_Stakes.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TextBox_Stakes.Value
ws.Cells(iRow, 2).Value = Me.TextBox_Struts.Value
ws.Cells(iRow, 3).Value = Me.TextBox_wire.Value
ws.Cells(iRow, 4).Value = Me.TextBox_Netting.Value
ws.Cells(iRow, 5).Value = Me.TextBox_Job.Value
ws.Cells(iRow, 6).Value = Me.TextBox_Date.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.TextBox_Stakes.Value = ""
Me.TextBox_Struts.Value = ""
Me.TextBox_wire.Value = ""
Me.TextBox_Netting.Value = ""
Me.TextBox_Job.Value = ""
Me.TextBox_Date.Value = ""
Me.TextBox_Stakes.SetFocus
End Sub
If anyone could help me out with any advice i would really appreciate it!
Thanky you very much for taking the time to read this, If you require any additional info please ask
Bookmarks