VBA 'Too many line continuations' error stopping macro from applying filter

bgrice

New Member
Joined
Feb 19, 2018
Messages
24
Hi. I have a workbook that copies a sheet from another workbook and applies some filters. The sheet contains about 3000 product lines. One of the filters I apply simply filters out any discontinued products where the options for the column are just 'discontinued', 'reinstated' or 'blank' and this works fine. However, I am trying to have the code apply a filter to a column that contains the prices of these products and to filter out any lines where the price is 0 (zero). While this is easy to do manually by just unchecking '0', I am having trouble getting it run through code. I have had a look at the code via the macro recorder and an error appears stating 'Too many line continuations.'

With 3000 product lines and each product potentially having a different price, the issue I believe is that the code wants to list all prices except 0 (zero) and with so many different prices it causes this error.

Is there any way to write the code to instruct it what to exclude i.e. just zero, as opposed to what to include i.e. everything other than zero?

I found that a similar question has been asked before but it doesn't appear to have a solution, or at least one that would work in this case.

Thanks.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You can filter for not 0 using the criteria "<>0"
 
Upvote 0
Solution
Hi Fluff. Thank you. I can't seem it get it work though. The code I have, which is below, seems to just uncheck all options. What am I doing wrong? Thanks for your help.

VBA Code:
Selection.AutoFilter Field:=4, Criteria1:="<>0"
 
Upvote 0
That code should just remove any value that equals 0 & leave the rest visible.
 
Upvote 0
Thank you. I have discovered the issue is that the numbers are stored as text. The solution worked once I corrected that. Much appreciated.
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top