+ Reply to Thread
Results 1 to 11 of 11

VBA Filtering Columns based on Cell Value for multiple columns

  1. #1
    Registered User
    Join Date
    07-22-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    30

    VBA Filtering Columns based on Cell Value for multiple columns

    Hi forum,

    I am trying to use VBA to filter the example data attached based on an input value. I have found some code to filter a table using a cell value that only applies to one column, but I need the input value to apply to a range of columns. In the example, I have columns for Q1, Q2, Q3, Q4 sales. I would like to input a value into e.g. cell H1 = 200, then the VBA will filter the table pulling through only the rows of data where in at least one instance (in either Q1, Q2, Q3, Q4) the sales of that particular person was greater than 200. So the value needs to apply to more than one column.

    Any help would be appreciated!

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    If you accept the use of column G as extra working column next code can help
    NB: This column can be somewhere else but can be useful for end user
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by PCI; 08-30-2014 at 03:50 PM. Reason: Additional info added
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    hi MikeRoot, option, please check attachment, enter value in H1 on Sheet1
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Another way without extra column
    Perhaps something missing for end user ...!
    Please Login or Register  to view this content.
    Last edited by PCI; 08-30-2014 at 04:34 PM. Reason: Typo

  5. #5
    Registered User
    Join Date
    07-22-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    30

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Hi PCI and Watersev,

    Thank you both for your suggestions, both really helpful! And achieve what I want them to.

    Amazing work, you've saved me a lot of work! Thank you!

    Mike

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Hi Mike,

    I wrote one too:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  7. #7
    Registered User
    Join Date
    07-22-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    30

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Hi guys,

    I appreciate the help - really is exactly what I was after!

    I was wondering if it is possible to adapt it so that any values that are less than the input threshold (H1) would be return at "<H1 Value"? Currently, I am using Watersev's code, so adaptions to that would be amazing!

    Thanks for the help - this would be an added bonus and would eliminate a further formula step

    Thanks!

    Mike

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    "any values that are less than the input threshold (H1) would be return at "<H1 Value"?"
    How would you like these values to be set in one cell: Do we use something like "/" between values ?
    If yes, see attached
    Attached Files Attached Files
    Last edited by PCI; 08-30-2014 at 08:00 PM. Reason: Typo

  9. #9
    Registered User
    Join Date
    07-22-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    30

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Hi PCI,

    I appreciate your patience. Ideally I am looking for about output of a table displays all the values great than H1, but all the values within the table that are less H1 rather than displaying their actual value to simply display <"H1" (whatever the value of H1 is).

    Apologies about the lack of clarity!

    Mike

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Mike,
    " rather than displaying their actual value to simply display <"H1"" , it means you want to erase data when value is smaller then H1 and replace it by "<H1 value".
    If yes we going to lose data, no?
    Can send you a screen shot (or Excel of course) of what you would like
    PCI
    Last edited by PCI; 08-31-2014 at 10:19 AM. Reason: Typo

  11. #11
    Registered User
    Join Date
    07-22-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    30

    Re: VBA Filtering Columns based on Cell Value for multiple columns

    Hi PCI,

    Great point! Don't think I have fully thought this through as you're right I'd lose the data, then if I then changed the value in H1 it would need to update based on the overwritten data.

    Not to worry! Thanks for your help really appreciated and as I said the main problem I had has been resolved.

    Thanks,

    Mike

+ 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] Copy/Paste multiple columns as values based on another columns criteria
    By Dgp2012 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-28-2013, 06:50 AM
  2. Filtering multiple Columns
    By QZJ00 in forum Excel General
    Replies: 4
    Last Post: 10-16-2012, 11:54 PM
  3. Replies: 5
    Last Post: 10-01-2010, 05:00 AM
  4. filtering based on multiple columns within a range.
    By CJPHX in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2010, 03:02 AM
  5. Filtering Multiple Columns
    By JOGIER in forum Excel General
    Replies: 18
    Last Post: 02-09-2008, 05:30 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