VBA table filter not working..
Results 1 to 3 of 3

Thread: VBA table filter not working..
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Location
    Surrey
    Posts
    155
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA table filter not working..

    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

  2. #2
    Board Regular
    Join Date
    Apr 2015
    Posts
    182
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA table filter not working..

    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.

  3. #3
    Board Regular
    Join Date
    Mar 2016
    Location
    Surrey
    Posts
    155
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA table filter not working..

    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

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •