Results 1 to 5 of 5

Compile Error syntax error

Threaded View

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    5

    Compile Error syntax error

    An error appears when using the user form
    this is the part of the code that is wrong according to excel, if someone could help me out id appreciate it so much.

    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
    This is the full code:

     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_name.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_name.Value
    ws.Cells(iRow, 2).Value = Me.textbox_surname.Value
    ws.Cells(iRow, 3).Value = Me.textbox_age.Value
    ws.Cells(iRow, 4).Value = Me.textbox_gender.Value
    
    MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
    'clear the data
    Me.textbox_name.Value = ""
    Me.textbox_surname.Value = ""
    Me.textbox_age.Value = ""
    Me.textbox_gender.Value = ""
    Me.textbox_name.SetFocus
    Last edited by ixelister; 02-23-2014 at 03:16 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. [SOLVED] first timer using VB to cut and paste macro - getting compile error syntax error
    By jopedder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2013, 11:45 AM
  3. [SOLVED] Compile Error : Syntax Error
    By sagar007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2013, 08:29 AM
  4. [SOLVED] Compile Error: Expected Expression, Syntax Error
    By gjohn282 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 11:28 PM
  5. Syntax Error and Compile Error: Expected Line Number or Label...
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2011, 09:59 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