+ Reply to Thread
Results 1 to 8 of 8

Too many line continuations

  1. #1
    Forum Contributor
    Join Date
    11-19-2014
    Location
    United States
    MS-Off Ver
    2010
    Posts
    137

    Too many line continuations

    In a column 3 I tend to keep on accumulating values that need to be removed. I now have too many values in that column now that I am getting an error of "Too many line continuations." How do I resolve this?

    For i = Cells(Rows.Count, 3).End(xlUp).Row To 1 Step -1
    If Cells(i, 4).Value = "INIT" Or Cells(i, 4).Value = "DES" Or _
    Cells(i, 3).Value = 1908425 Or _
    Cells(i, 3).Value = 1632492 Or _
    Cells(i, 3).Value = 2588948 Or _
    Cells(i, 3).Value = 2644451 Or _
    Cells(i, 3).Value = 2654319 Or _
    Cells(i, 3).Value = 1794637 Or _
    Cells(i, 3).Value = 1722139 Or _
    Cells(i, 3).Value = 2655788 Or _
    Cells(i, 3).Value = 1796065 Or _
    Cells(i, 3).Value = 1489608 Or _
    Cells(i, 3).Value = 1794637 Or _
    Cells(i, 3).Value = 1770914 Or _
    Cells(i, 3).Value = 1495217 Or _
    Cells(i, 3).Value = 1492028 Or _
    Cells(i, 3).Value = 1983020 Or _
    Cells(i, 3).Value = 2122683 Or _
    Cells(i, 3).Value = 1507671 Or _
    Cells(i, 3).Value = 1593761 Or _
    Cells(i, 3).Value = 2458957 Or _
    Cells(i, 3).Value = 1782458 Or _
    Cells(i, 3).Value = 2240527 Or _
    Cells(i, 3).Value = 2319018 Or _
    Cells(i, 3).Value = 2084908 Or _
    Cells(i, 3).Value = 2029397 Or _
    Cells(i, 3).Value = 1896445 Or _
    Cells(i, 3).Value = 1908373 And Cells(i, 22) = 11400 Or _
    Cells(i, 5).Value = "1234567" Or Cells(i, 5).Value = "1234567" Then _
    Rows(i).Delete
    Next
    For Each cell In ActiveSheet.UsedRange
    cell.Value = Trim(cell)
    Next cell




    Thanks for the help.

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: Too many line continuations

    I'd just put more on a single line. Or you can use a Select Case, but with multiple cells to check values of, collapsing the If would be cleaner:

    Please Login or Register  to view this content.
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Too many line continuations

    Something like this
    Please Login or Register  to view this content.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,477

    Re: Too many line continuations

    Interesting that you've thrown an And in there:

    Please Login or Register  to view this content.
    and that you've duplicated the:

    Please Login or Register  to view this content.
    I'd be inclined to bracket the And as I'm not entirely sure how it will work out in the midst of all those Ors.

    Please Login or Register  to view this content.
    If it were me, I'd put all those codes in a "Configuration" sheet, which you can hide, and use Countif to check if the code is present in the list. That makes it easier to make changes to the list without having to adapt your code ... with maybe the exception of the And.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Too many line continuations

    I think it might be worth it to introduce a boolean variable


    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Too many line continuations

    Hi,

    If it were me I'd approach this from a different angle. I don't like using time consuming loops when there is much more efficient functionality available.
    In this case I'd create a list of all the values that need deleting and name it 'mylist'.

    Then in a helper column alongside your data add a MATCH formula that determines whether to keep the row or not. i.e.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The helper column formula should be adapted to include the special conditions for the different And/Or combination you show as the last items but this should be relatively trivial.


    Assuming the helper column is column Z
    Then your macro can be a simple autofilter

    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 11-09-2015 at 11:01 AM. Reason: End WIth missing
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,477

    Re: Too many line continuations

    Agree with the approach. Formula could be a little shorter:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or even
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Regards, TMS

  8. #8
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: Too many line continuations

    I do this all the time in practice. Much faster. Also, I'll typically sort the data on the Keep/Delete key, as deleting non-continuous ranges takes additional time, and if there are enough individual ranges, can tank Excel completely.

+ 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. VBA Refresh ODBC Connection with too Many Line Continuations
    By icraig8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2015, 10:15 PM
  2. [SOLVED] Too Many Line Continuations - 24 lines limit
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2014, 03:02 AM
  3. Too Many Line Continuations
    By sidney102 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2013, 07:10 PM
  4. Too Many Line continuations?? VB Macro
    By mkingsley in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-28-2013, 12:23 AM
  5. VB error code: too many line continuations
    By rarias in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2013, 06:01 PM
  6. Too many line continuations
    By TonyforVBA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2010, 11:26 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