+ Reply to Thread
Results 1 to 6 of 6

VBA Selection and Filters

  1. #1
    Registered User
    Join Date
    07-13-2018
    Location
    London
    MS-Off Ver
    Work: Excel 2016 (16.0.5005.1000 32bit) Home: Excel for M365 MSO (16.0.13001.20338 64bit)
    Posts
    25

    VBA Selection and Filters

    Hello,

    This is an obscenely basic problem and I'm embarrassed to even be asking but I'm having trouble working through what is selected when a filter is employed on a list; for this example I have a have a simple list of items in cells a1-a6 (filter is on a1):

    Filter
    cake
    snacks
    apples
    carrots
    peas

    If I filter this list to just 'cake' and 'peas' then select (click and drag) a box around those two and copy+paste to a different area of the sheet then I get just cake and peas. However if I run a simple macro on that same selection it performs that action on all of the cells in between as well:

    Please Login or Register  to view this content.
    I just want the macro to perform its actions on the two selected cells (as the copy and paste did). It should be simple and I know it's just something about the way I'm calling the selection but for the life of me I cant get it to work right and my google-foo is failing me (too many hits throwing any useful search off!). Can anyone help?

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,987

    Re: VBA Selection and Filters

    One way is to assess the row height.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-13-2018
    Location
    London
    MS-Off Ver
    Work: Excel 2016 (16.0.5005.1000 32bit) Home: Excel for M365 MSO (16.0.13001.20338 64bit)
    Posts
    25

    Re: VBA Selection and Filters

    Ah that's cunning, so are filtered rows just 0 height rows?

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,987

    Re: VBA Selection and Filters

    I would say that there is more that one reason why a row could have a zero height but a filter is one of them.

  5. #5
    Registered User
    Join Date
    07-13-2018
    Location
    London
    MS-Off Ver
    Work: Excel 2016 (16.0.5005.1000 32bit) Home: Excel for M365 MSO (16.0.13001.20338 64bit)
    Posts
    25

    Re: VBA Selection and Filters

    Just confirming your suggestion worked a treat, thank you for the help!

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,987

    Re: VBA Selection and Filters

    You're welcome. Thanks for confirming, it's appreciated.

+ 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. Replies: 12
    Last Post: 09-27-2019, 01:45 AM
  2. Replies: 5
    Last Post: 07-13-2016, 03:39 PM
  3. [SOLVED] Rename Sheets as per selection from Filters
    By E5254730 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2015, 09:44 AM
  4. Filters Based on Selection (Macros)
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-21-2015, 04:23 AM
  5. Two worksheet selection changes for same pivot, different filters
    By cp41 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2013, 12:20 PM
  6. Multiple filters, dependent on previous selection
    By Amy.H in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-25-2012, 09:10 AM
  7. Replies: 4
    Last Post: 07-24-2012, 01:21 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