Results 1 to 5 of 5

Thread: [RESOLVED] Excel Syntax Error

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Resolved [RESOLVED] Excel Syntax Error

    This is part of a sub that does some things with 4 digit strings. cel is a range. This code shows a syntax error; what's wrong with it?

    Code:
     For Each cel In MyRange
                If Left$(Cells(lngRow, "CR"), 3) = cel.value or_
                   Left$(Cells(lngRow, "CR"), 2) & Right$(Cells(lngRow, "CR"), 1) = cel.value  or _
                   Right$(Cells(lngRow, "CR"), 3) = cel.value or _
                   left$(Cells(lngRow, "CR"), 1) & Right$(Cells(lngRow, "CR"), 2) = cel.value then
                    Stop
                End If
            Next

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Excel Syntax Error

    Is it just the fact that there is no space between "or" and "_" in the first line?

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Excel Syntax Error

    Quote Originally Posted by OptionBase1 View Post
    Is it just the fact that there is no space between "or" and "_" in the first line?
    Don't see anything else, either.

    Trying to figure out what you're trying to do with those Left/Right.
    Looks like you're trying to find a pattern
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Excel Syntax Error

    You need a space between or and _ in the first line
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  5. #5

Posting Permissions

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



Click Here to Expand Forum to Full Width