+ Reply to Thread
Results 1 to 4 of 4

Compile Error : Syntax Error

  1. #1
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Compile Error : Syntax Error

    Hey All

    I am very new to VBA so please be patient

    within my VBA i have put the following logic

    If Mid(Str1, 3, 2) = "79" Or _
    Mid(Str1, 3, 2) = "81" Or _
    Mid(Str1, 3, 2) = "82" Or _
    Mid(Str1, 3, 2) = "85" Or _
    Mid(Str1, 3, 2) = "88" _

    Then



    However when ever i run it , il get the following error message “

    Any ideas?

  2. #2
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Compile Error : Syntax Error

    The full vba is



    Sub extractDetail()

    Open "C:\Temp\Ecom.txt" For Input As 1

    Dim Str1 As String
    Dim rowx As Long
    Dim merchant As String
    Dim merchantName As String



    rowx = 9

    While Not EOF(1)


    Line Input #1, Str1

    If Mid(Str1, 1, 8) = "MERCHANT" Then
    Sheets("Low Level Results").Cells(rowx, 1).Value = Mid(Str1, 18, 12)
    Sheets("Low Level Results").Cells(rowx, 2).Value = Mid(Str1, 57, 30)

    merchant = Mid(Str1, 18, 12)
    merchantName = Mid(Str1, 57, 30)


    While Mid(Str1, 1, 5) <> "TOTAL"

    If Mid(Str1, 3, 2) = "79" Or _
    Mid(Str1, 3, 2) = "81" Or _
    Mid(Str1, 3, 2) = "82" Or _
    Mid(Str1, 3, 2) = "85" Or _
    Mid(Str1, 3, 2) = "88" _

    Then


    With Sheets("Low Level Results")

    .Cells(rowx, 1).Value = merchant
    .Cells(rowx, 2).Value = merchantName
    .Cells(rowx, 3).Value = Mid(Str1, 3, 2) ' Product
    .Cells(rowx, 4).Value = Mid(Str1, 8, 12) ' Fully Secure tran count
    .Cells(rowx, 5).Value = Mid(Str1, 9, 7) ' Fully Secure amount
    .Cells(rowx, 6).Value = Mid(Str1, 9, 7) ' Merchant Secure tran count
    .Cells(rowx, 7).Value = Mid(Str1, 9, 7) ' Merchant Secure amount
    .Cells(rowx, 8).Value = Mid(Str1, 9, 7) ' Non-Secure tran count
    .Cells(rowx, 9).Value = Mid(Str1, 9, 7) ' Non-Secure amount
    .Cells(rowx, 10).Value = Mid(Str1, 9, 7) ' Total E-Com tran count
    .Cells(rowx, 11).Value = Mid(Str1, 9, 7) ' Total E-Com amount

    rowx = rowx + 1






    End With

    End If


    Line Input #1, Str1



    Wend

    End If


    Wend




    Close #1



    End Sub

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Compile Error : Syntax Error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Compile Error : Syntax Error

    Please ignore, this has now been resolved

+ Reply to Thread

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: Expected Expression, Syntax Error
    By gjohn282 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 11:28 PM
  4. Compile error: Syntax error
    By ttik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2011, 09:45 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