+ Reply to Thread
Results 1 to 5 of 5

Autofilter Excel VBA (from criteria on different sheet)

  1. #1
    Registered User
    Join Date
    08-02-2019
    Location
    Lahore
    MS-Off Ver
    proplus
    Posts
    2

    Exclamation Autofilter Excel VBA (from criteria on different sheet)

    Hi,

    I wish to apply autofilter on one of the fields with multiple criteria from a different sheet.

    I have a table with multiple columns and one of them is years. I want to apply filters to 3 different columns, but for the year column I wish to give a range of values to the filter (2022 to 2025).

    My code looks like this:

    ws.Range("A1:s1000").AutoFilter Field:=1, Criteria1:=sourcesheet.Range("A57").Value
    ws.Range("A1:S1000").AutoFilter Field:=5, Criteria1:=sourcesheet.Range("B57").Value
    ws.Range("A1:S1000").AutoFilter Field:=7, Criteria1:=sourcesheet.Range("C57").Value

    In the 3rd criteria, "C57" refers to value of 2022 in the source file but I want to include c57 to c60 to include 2023, 2024, 2025 in the filtered value.

    Would really appreciate some help on this.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Autofilter Excel VBA (from criteria on different sheet)

    untested
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-02-2019
    Location
    Lahore
    MS-Off Ver
    proplus
    Posts
    2
    Quote Originally Posted by AB33 View Post
    untested
    Please Login or Register  to view this content.
    Hi thank you for responding. But this isn't working
    Gives an error (run time error 438)

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: Autofilter Excel VBA (from criteria on different sheet)

    How about
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Autofilter Excel VBA (from criteria on different sheet)

    Forgotten to transpose it. Fluff has got it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] how to autofilter criteria in a range of column different sheet
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2021, 12:03 PM
  2. Autofilter with criteria from other sheet
    By flunzy in forum Excel General
    Replies: 3
    Last Post: 01-26-2017, 11:34 AM
  3. VBA to autofilter data based on set criteria into a new sheet
    By indik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2015, 04:54 PM
  4. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  5. Replies: 3
    Last Post: 10-22-2012, 05:23 PM
  6. Script, IF sheet has AutoFilter criteria, to unfilter...
    By tangcla in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2009, 06:33 PM
  7. [SOLVED] AutoFilter Pull Criteria from one sheet and custom filter on other
    By dtg_denver in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2005, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1