+ Reply to Thread
Results 1 to 14 of 14

Crazy Complicated - Advanced Filtering VBA based on cell value

  1. #1
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Question Crazy Complicated - Advanced Filtering VBA based on cell value

    Dear all,

    I am working on a global email communications report covering 12 markets.
    As per the screenshot attached, I would like to filter results based on the cell value in D3 ("Austria") whereas D3 is a drop-down listing all 12 markets in two variants (one is just the market e.g. "Austria" and one is "Austria_Trigger"). Based on what is selected in this drop down, a filter should be applied to all columns from row 14 to 8000 taking the campaign name as a reference (column D). Adding another layer of complexity: the sums of the results should only reflect the data of the visible rows once the filter is applied (if I filter manually, the sums include all hidden rows too, which is a problem).

    An example:
    If "Austria" is selected in D3, all results should filter and only show campaigns that contain "Austria" in the campaign name (however, EXCLUDING campaigns that contain "Austria_Trigger").
    If "Austria_Trigger" is selected in D3, all results should filter and only show all campaigns that contain "Austria_Trigger" in the campaign name (EXCLUDING campaigns that contain "Austria" without the _Trigger extension).
    The row displaying the sums for all results should change accordingly and only take data from the visible rows (not the filtered out ones).

    Untitled-1.jpg

    Hope this makes sense...

    Would this be possible with VBA? How would I need to assign the macro to the drop-down in order to work?

    Hope someone can help...would be highly appreciated!

    Thanks,
    Mat

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Hi Mat,

    To quickly answer your question about filtering:
    -only "Austria" while excluding "Austria_Trigger", you can use ="=Austria" as a Filter
    -only "Austria_Trigger" while excluding "Austria", you can use ="=Austria_Trigger*" as a Filter

    Regards,
    Rick

  3. #3
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    And to show only the sum of the filtered rows, you can use the function Subtotal in stead of Sum.

    So e.g. using
    Please Login or Register  to view this content.
    in stead of

    Please Login or Register  to view this content.
    Cheers,
    Rick
    Last edited by rkey; 09-03-2015 at 08:22 AM.

  4. #4
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    double post
    Last edited by rkey; 09-03-2015 at 08:20 AM. Reason: double post

  5. #5
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Hi Rick,

    This is great - thanks for your help. I'll try to use subtotal then.
    Can you let me know why you've included the 9 in this?:

    Please Login or Register  to view this content.
    Is there also a similar formula for average (e.g. "=subaverage")?

    Regarding your answer concerning filters:

    Please Login or Register  to view this content.
    I'm not quite sure if I understand. That would be a manual filter, right?
    I would like to automate this so depending on what markets select from the drop down, only the relevant campaigns would show up.

    I've attached the report with example data (had to zip it as too big to upload here)
    Performance_Report_2015.zip
    ...maybe this is of help to understand what I am trying to achieve?

    Thanks for your help and time - really appreciate it!

    Cheers,
    Mat

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  7. #7
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Hi John,

    Perfect! Thanks so much - that did the trick

    Sorry for asking, but are you able to help re my other inquiry? Still can't this automatic filter to work :-( It's a nightmare...

    Many thanks and happy Friday,
    Mat

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    First remove the current filter completely as you are using row 14 as a header so it will always be visible. Then right-click the Report Details tab, choose View Code and then paste this in:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  9. #9
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Hi John, Hi Rick,

    I'm playing with the following code at the moment, but it does not seem to work properly...
    Do you have an idea what I'm doing wrong? I'm on Excel 2010 if that makes any difference...

    Please Login or Register  to view this content.
    Thanks,
    Mat

  10. #10
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Hi Rory,

    OMG! You just saved my life! AMAZING! Works perfectly!!!
    Do you think it would be possible that if I select "INTERNATIONAL" from the dropdown, that all results are shown (i.e. no filter applied?).
    That would perfect...

    Thanks so much!
    Happy Friday,
    Mat

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Sure:

    Please Login or Register  to view this content.
    Last edited by romperstomper; 09-04-2015 at 08:42 AM.

  12. #12
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Pefect! Thanks

    I get a compile error "Invalid qualifier" highlighting the UCase$ bit... (I've added a close bracket as I felt it was missing...hope this didn't ruin it).

    Please Login or Register  to view this content.
    Appreciate your help.
    Let me know if I can return the favor somehow...

    Cheers,
    Mat

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    The bracket was missing but that's not where it goes. I've edited the code in my last post.

  14. #14
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Crazy Complicated - Advanced Filtering VBA based on cell value

    Yaaay! Works!! Thanks so much! Let me know if I can return the favor.

    Cheers and have a great weekend,
    Mat

+ 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] Help - Advanced filtering (or possibly formula) in one single cell
    By sx200n in forum Excel General
    Replies: 1
    Last Post: 10-10-2014, 11:23 AM
  2. Advanced filtering not working when a cell is focused on Pivottable...
    By sundar2182 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-01-2013, 12:18 PM
  3. [SOLVED] Unique Count Values by Advanced Filtering based upon UForm CBox Selection
    By Southfish in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-30-2012, 02:57 PM
  4. cell reference in advanced filtering
    By candiecane_81 in forum Excel General
    Replies: 4
    Last Post: 02-20-2012, 03:30 AM
  5. Advanced filtering using first letter of a cell
    By Tino XXL in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-16-2011, 04:41 AM
  6. Replies: 1
    Last Post: 08-25-2011, 05:44 PM
  7. Replies: 0
    Last Post: 08-01-2006, 04:15 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