Results 1 to 6 of 6

VBA userform problem with code (syntax error)

Threaded View

Odowd VBA userform problem with... 04-27-2016, 08:27 PM
humdingaling Re: VBA beginner HELP 04-27-2016, 08:57 PM
Odowd Re: VBA beginner HELP 04-27-2016, 09:01 PM
TMS Re: VBA beginner HELP 04-27-2016, 09:12 PM
Odowd Re: VBA beginner HELP 04-27-2016, 09:19 PM
humdingaling Re: VBA userform problem with... 04-27-2016, 09:23 PM
  1. #1
    Registered User
    Join Date
    04-27-2016
    Location
    Manchester
    MS-Off Ver
    Excel
    Posts
    7

    VBA userform problem with code (syntax error)

    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
    Last edited by Odowd; 04-27-2016 at 09:18 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner help
    By saratu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 02:32 PM
  2. i am a beginner
    By saeedpak13 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-25-2014, 08:42 AM
  3. Beginner!
    By coffeemints in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-28-2013, 07:22 PM
  4. Beginner
    By cawwat85 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-28-2013, 01:34 PM
  5. Beginner If Then Help
    By Than924 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2012, 09:38 AM
  6. Beginner
    By ruhat145 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-01-2012, 10:05 PM
  7. [SOLVED] Beginner's help
    By jello in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-08-2005, 12:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1