VBA Filter for $-

tanyaleblanc

Board Regular
Joined
Mar 16, 2019
Messages
145
I'm trying to filter, not sure why its not workig, I seem to always have an issue with the does not <>, there's a formula in that cell, but it shouldn't matter I wouldn't think.

Code:
With ActiveSheet        .AutoFilterMode = False
        With Range("a2:m2" & lRow)
            .AutoFilter
            .AutoFilter Field:=2, Criteria1:="<>$- ", Operator:=xlAnd, Criteria2:="<>#N/A"
            MsgBox "stop"


'filter not working should pickup everything that's not $-

it's picking up, do not include N/A's but it's including the $- for some reason.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Have you tried using the Macro recorder to see what the difference would be when you use that code.
 
Upvote 0
Its just a filter, if I use the macro recorder, I can only filter the column and choose the the data I want to see, I don't know how else to do it.
 
Upvote 0
Hello Tanya,

Change this line:-

Code:
With Range("a2:m2" & lRow)

to
Code:
With Range("a1:m" & lRow)

I'm assuming that you have headings in Row1 with data starting in Row2

or try it this way:-

Code:
With ActiveSheet.Range("A1", ActiveSheet.Range("M" & ActiveSheet.Rows.Count).End(xlUp))
        .AutoFilter 2, "<>" & "#N/A", xlAnd, "<>" & "$-"
End With

If this too doesn't work then a reply to Pike's question may unlock the mystery for you.

Cheerio,
vcoolio.
 
Upvote 0
Yes, it is the accounting cell format, I changed it to currency and updated the code to <>$0.00 and it works, tks again
 
Last edited:
Upvote 0
Hello Tanya,

my headings are in row 2 and data starting in row 3, but the code above is still not working.

In that case, change:-

Code:
With Range("A1:M" & lRow)

to
Code:
With Range("[COLOR=#ff0000]A2[/COLOR]:M" & lRow)

and
Code:
With ActiveSheet.Range("A1", ActiveSheet.Range("M" & ActiveSheet.Rows.Count).End(xlUp))

to
Code:
With ActiveSheet.Range("[COLOR=#ff0000]A2[/COLOR]", ActiveSheet.Range("M" & ActiveSheet.Rows.Count).End(xlUp))

However, based on your post#6, you now have the code working.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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