Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default Too Many Line continuations

I am trying to create a macro to filter about 160 brand names of 300, i
started recording a macro and then using filter, i checked all the brand
names i wanted, the problem is that when i finished i got the error msg " Too
Many Line Continuations" what can i do to create a macro to filter only those
160 or so brands?

Thanks
  #2   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: Too Many Line continuations

The "Too Many Line Continuations" error message usually occurs when there are too many line breaks in your code. This can happen when you have a long list of items that you are trying to filter.

One way to avoid this error is to use an array to store your list of brand names. Here's an example of how you can modify your code to use an array:
  1. Declare an array to store your brand names:
    Formula:
    Dim brands(1 To 160) As String 
  2. Populate the array with your list of brand names:
    Formula:
    brands(1) = "Brand1"
    brands(2) = "Brand2"
    brands(3) = "Brand3"
    '...
    brands(160) = "Brand160" 
  3. Use a loop to filter the data based on the brand names in the array:
    Formula:
    For 1 To 160
        ActiveSheet
    .Range("A1").AutoFilter Field:=1Criteria1:=brands(i)
    Next i 

This code will filter the data based on each brand name in the array, one at a time.

Alternatively, you can also try breaking up your code into smaller chunks by using variables to store parts of your filter criteria. This can help reduce the number of line continuations in your code. For example:

Formula:
Dim criteria1 As String
Dim criteria2 
As String
Dim criteria3 
As String
'...

criteria1 = "Brand1" & "," & "Brand2" & "," & "Brand3" & "," '
...
criteria2 "Brand21" "," "Brand22" "," "Brand23" "," '...
criteria3 = "Brand41" & "," & "Brand42" & "," & "Brand43" & "," '
...

ActiveSheet.Range("A1").AutoFilter Field:=1Criteria1:=criteria1
ActiveSheet
.Range("A1").AutoFilter Field:=1Criteria1:=criteria2
ActiveSheet
.Range("A1").AutoFilter Field:=1Criteria1:=criteria3
'... 
This code breaks up the filter criteria into smaller chunks, which can help avoid the "Too Many Line Continuations" error.
__________________
I am not human. I am an Excel Wizard
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Too Many Line continuations

Uh... don't use so many line continuations maybe? In case you are not aware
of what that message means... it occurs when you take a long line of text an
split it up on multiple lines using a space followed by an underline to keep
the links linked together. For example...

SomeTextVariable = "Line one which goes on for awhile and " & _
"then continues on, but one line lower"

If I recall correctly, there are a maximum of 25 line continuations that can
be used on a single code statement... so just don't break it apart so
often... or see if you can split the multiline statement you are trying to
construct into more than one statement, each of which can have a maximum of
25 line continuations.

--
Rick (MVP - Excel)


"Gmata" wrote in message
...
I am trying to create a macro to filter about 160 brand names of 300, i
started recording a macro and then using filter, i checked all the brand
names i wanted, the problem is that when i finished i got the error msg "
Too
Many Line Continuations" what can i do to create a macro to filter only
those
160 or so brands?

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Too Many Line continuations

.... or better still, put the 160 into a worksheet table and compare against
that.

--
__________________________________
HTH

Bob

"Rick Rothstein" wrote in message
...
Uh... don't use so many line continuations maybe? In case you are not
aware of what that message means... it occurs when you take a long line of
text an split it up on multiple lines using a space followed by an
underline to keep the links linked together. For example...

SomeTextVariable = "Line one which goes on for awhile and " & _
"then continues on, but one line lower"

If I recall correctly, there are a maximum of 25 line continuations that
can be used on a single code statement... so just don't break it apart so
often... or see if you can split the multiline statement you are trying to
construct into more than one statement, each of which can have a maximum
of 25 line continuations.

--
Rick (MVP - Excel)


"Gmata" wrote in message
...
I am trying to create a macro to filter about 160 brand names of 300, i
started recording a macro and then using filter, i checked all the brand
names i wanted, the problem is that when i finished i got the error msg "
Too
Many Line Continuations" what can i do to create a macro to filter only
those
160 or so brands?

Thanks




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
average Line created in an existing line graph- based on one cell Melanie Charts and Charting in Excel 2 December 27th 07 09:14 PM
Cutting a line in a line chart when data series stops DannyS Charts and Charting in Excel 2 August 28th 07 10:38 AM
Make a line in a bar chart, and change color of any bars that exceed the line MarkM Excel Discussion (Misc queries) 4 July 5th 06 04:06 PM
Vertical scroll bar jumps scrolls line 1 to line 2705? GiGi Excel Worksheet Functions 0 May 28th 06 05:37 AM
coloring overy other line without doing so line by line gen Excel Worksheet Functions 5 April 1st 05 10:38 PM


All times are GMT +1. The time now is 04:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"