+ Reply to Thread
Results 1 to 3 of 3

Worksheet_Change/SelectionChange: Detect if a has a filter caused the change?

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    584

    Worksheet_Change/SelectionChange: Detect if a has a filter caused the change?

    I have a procedure in the Worksheet_SelectionChange.

    I see that if I go over and re-sort the table on that worksheet, the event is triggered and the code runs.

    I want to know if the WorkSheet_SelectionChange event is triggered by the user clicking a different item in the table, or if it was caused by imposing some filter.

    The reason is that IF a specific userform is open I need to completely reset that form ONLY if a filter has been invoked; otherwise, the form has it's own mechanism to reflect changes in the table. If the table has been filtered, the comboboxes need their lists reset to match the table.

    Is there a way to trap this?

    Thank-you!

    edit: As additional information, I have tried toying with the autofilter and autofilter properties(?) of the worksheet, but they do not trip if all that has been done is the user "simply" sorted the table in another order; i.e., ascending vs. descending. I suppose the working answer for now is to check autofilter and autofiltermode AND whether the same value is still in cell A1, but not only does that seem to me rather, well, lame, but also I suspect it won't always work-
    Last edited by brucemc777; 04-13-2016 at 04:25 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Worksheet_Change/SelectionChange: Detect if a has a filter caused the change?

    Take a look at target.address. If it is the filter cell, then do A, if not do B.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    584

    Re: Worksheet_Change/SelectionChange: Detect if a has a filter caused the change?

    Thank-you!

    I see now that if I change the cell a cell address is reported back by target.address, but if the filter is used to re-sort, a multi-cell range is reported back. That is very helpful!

+ 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. Worksheet_change event (not working to execute filter)
    By Rudo123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-26-2016, 03:58 PM
  2. Can VBA reference change in cell value caused by formula?
    By gabbana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2016, 11:44 AM
  3. [SOLVED] detect if worksheet_change is triggered by delete button
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-16-2015, 07:00 PM
  4. How to prevent SelectionChange event firing before Change event?
    By franklyn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 05:17 AM
  5. [SOLVED] Worksheet_change, how to detect a range is changed instead only 1 cell?
    By vin1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2012, 06:16 AM
  6. what takes precedence between change and selectionchange?
    By susan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2006, 03:30 AM
  7. Remember SelectionChange range in the Change sheet event?
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2005, 06:06 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