+ Reply to Thread
Results 1 to 4 of 4

Start a new line in IF without compile error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-19-2013
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    297

    Start a new line in IF without compile error

    Is it possible to start a new line in an IF without the compile error (i.el that there is no 'Then'). So I have the line:

    If Not vData(i, 2) = vCriteria And Not vData(i, 3) = vCriteria And Not vData(i, 4) = vCriteria And Not vData(i, 5) = vCriteria And Not vData(i, 6) = vCriteria And Not vData(i, 7) = vCriteria And Not vData(i, 8) = vCriteria And Not vData(i, 9) = vCriteria And Not vData(i, 10) = vCriteria Then
    I want to start a new line say half way through so I don't have to side scroll to see it- but if I do that because the line doesn't end with a 'Then' there is a compile error.

    Alternatively, is there way I could just condense my line?

    Even if this is possible it would still be useful to know the answer to the original question though.

    Thanks guys

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Start a new line in IF without compile error

    hi strud. put a space & an underscore:
    If Not vData(i, 2) = vCriteria And Not vData(i, 3) = vCriteria And Not vData(i, 4) = vCriteria And Not vData(i, 5) = _
    vCriteria And Not vData(i, 6) = vCriteria And Not vData(i, 7) = vCriteria And Not vData(i, 8) = vCriteria And Not vData(i, 9) _
    = vCriteria And Not vData(i, 10) = vCriteria Then

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Start a new line in IF without compile error

        If Not vData(i, 2) = vCriteria And _
           Not vData(i, 3) = vCriteria And _
           Not vData(i, 4) = vCriteria And _
           Not vData(i, 5) = vCriteria And _
           Not vData(i, 6) = vCriteria And _
           Not vData(i, 7) = vCriteria And _
           Not vData(i, 8) = vCriteria And _
           Not vData(i, 9) = vCriteria And _
           Not vData(i, 10) = vCriteria Then
           
        End If
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    04-19-2013
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    297

    Re: Start a new line in IF without compile error

    Thanks for the help guys

+ 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. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  2. [SOLVED] Continue code on next line: Compile Error: expected list separator or )
    By ike609 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2012, 08:28 AM
  3. Compile error in vba code in one line
    By prabhuduraraj09 in forum Excel General
    Replies: 1
    Last Post: 05-26-2012, 07:32 AM
  4. GoTo compile error: "Expected: line number or label"
    By elfsprin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2011, 09:21 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