+ Reply to Thread
Results 1 to 3 of 3

VBA to change filters based on cells

  1. #1
    Registered User
    Join Date
    01-29-2018
    Location
    California
    MS-Off Ver
    2016
    Posts
    3

    VBA to change filters based on cells

    In this code, all rows not meeting the criteria "<>RAY" get deleted, leaving just what I really want, which is all rows containing RAY.

    ws1.Cells.AutoFilter
    ws1.Range("B2:R2000").Value = ws2.Range("A7:Q2005").Value
    ws1.Cells.AutoFilter Field:=2, Criteria1:= _
    "<>RAY"
    myLoads.Range("B2:R2000").SpecialCells(xlCellTypeVisible).EntireRow.Delete
    myLoads.ShowAllData

    I need to be able to change this other names besides RAY, which would be indicated by a cell reference.

    Not sure what Im looking for tho..

    Im pretty new to this so keep it simple for me please!

    TIA

  2. #2
    Registered User
    Join Date
    09-26-2016
    Location
    Japan
    MS-Off Ver
    Office 2013
    Posts
    6

    Re: VBA to change filters based on cells

    The most simple code is
    Criteria1:="<>" & Range("A1").Value

    If you have two more criterias(e.g range("B1:B5")), it should be as below.
    Please Login or Register  to view this content.
    I think the red parts would be "ws1".

    Hope this helps.

  3. #3
    Registered User
    Join Date
    01-29-2018
    Location
    California
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA to change filters based on cells

    Workes like a charm

+ 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. Change order of static cells based on dynamic formula based cells
    By S_O_A_L in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2016, 04:33 AM
  2. Filter report filters based upon previous report filters!!??
    By jackie_m in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-21-2015, 05:17 AM
  3. Pivot Filters to change simulataneously with other pivot filters
    By ScottBeatty in forum Excel Charting & Pivots
    Replies: 9
    Last Post: 07-02-2014, 10:48 AM
  4. [SOLVED] Change locked filters
    By Runnin L8 in forum Excel General
    Replies: 3
    Last Post: 11-23-2013, 06:27 PM
  5. Change filters and print based off of a list
    By Pergo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2013, 04:15 PM
  6. Changing the Pivot Table Filters based on Multiple Cells
    By dbnhc8 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-28-2012, 02:37 PM
  7. Change pivot table filters on VBA userform combox box change?
    By Teemu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-16-2011, 05:49 AM

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