VBA table filter not working..

BenGee

Board Regular
Joined
Mar 5, 2016
Messages
155
Hi

This part of my code applies a greater than or equal to filter successfully;
Code:
        If ActiveSheet.Range("G3").Value <> "" Then
            .AutoFilter Field:=7, Criteria1:=">=" & ActiveSheet.Range("G3").Value
        End If
But I want it to be equal to, but when I change it, it doesn't filter. I've tried 2 variations;
Code:
        If ActiveSheet.Range("G3").Value <> "" Then
            .AutoFilter Field:=7, Criteria1:="=" & ActiveSheet.Range("G3").Value
        End If
And;
Code:
        If ActiveSheet.Range("G3").Value <> "" Then
            .AutoFilter Field:=7, Criteria1:=ActiveSheet.Range("G3").Value
        End If
The contents of G3 and field 7 are in currency format. If I change to text, the equals filter works but I need to keep as currency + I can't work out why it only works for >=

Thanks in advance for your help
 

GR00007

Board Regular
Joined
Apr 22, 2015
Messages
184
The values you are trying to match are formatted as currency - but that doesn't show what the actual value of the cell is. Excel will round to the decimals chosen to view and any value that doesn't match exactly to what you have in G3 will not "=". Please check both what the actual values of G3 and what you are matching to actually do match.
 

BenGee

Board Regular
Joined
Mar 5, 2016
Messages
155
Ok, thanks for your help.

All the value look the same. For example, the value of G3 is "1000" (showing as a currency of £1000), and, in my table there is a matching value of "1000" also showing as a currency of £1000. So still unsure why it's not recognising this when the code is "=" but can recognise these values when it's "<=".

Ive converted all to text and it's working however so will do.

Thanks for your help :)
 

Forum statistics

Threads
1,085,960
Messages
5,386,957
Members
402,026
Latest member
rudyd06

Some videos you may like

This Week's Hot Topics

Top