+ Reply to Thread
Results 1 to 5 of 5

VBA to filter based on highlighted cell value in a column the cells sits

  1. #1
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2007
    Posts
    185

    VBA to filter based on highlighted cell value in a column the cells sits

    Hello All,

    I have compiled a little code for a macro to filter based on a highlighted cell value. It is however, for a specific column.

    Is there a way to adapt a filter field to be picked up by where the cell is? I mean to insert the cell value into the field that represents the column in which the highlighted cell sits?

    Column A is filter field 1 ...

    I cannot find anything that will be clear enough to me to understand how I can adapt it to make it happen. Below is the code I used:


    Please Login or Register  to view this content.
    I need to adapt the part where it says ".AutoFilter Field:=2," to count which column it is to be applied to.

    Any ideas appreciated.

    Thank you in advance.

    Simon
    ...and this is when I walk in, dressed fully in white...

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to filter based on highlighted cell value in a column the cells sits

    Hi,

    change to

    Please Login or Register  to view this content.
    Incidentally you don't need the .Activate code. .Activate or .Select are rarely needed and just slow things down since VBA has to jump back to the Excel application and return. Not so much a problem here but in loop there is a big time overhead.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: VBA to filter based on highlighted cell value in a column the cells sits

    Well - if you've got the cell selected:

    Please Login or Register  to view this content.
    Last edited by xladept; 11-22-2018 at 01:35 PM.
    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

  4. #4
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Birmingham, UK
    MS-Off Ver
    2007
    Posts
    185

    Re: VBA to filter based on highlighted cell value in a column the cells sits

    Works beautifully.

    Thank you.

    I am quite new to the VBA and work with what I have seen already. I keep working at copy and paste method and adjust for the needs.

    Thank you for your feedback.

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

    Re: VBA to filter based on highlighted cell value in a column the cells sits

    You're welcome and thanks for the rep!

+ 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] UNSOLVED - Identify highlighted cells in column, copy cell value to column B of active row
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2014, 04:42 AM
  2. Add Filter to top row and reset page so (A1) is only cell highlighted
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 07:38 AM
  3. [SOLVED] code to filter a column based on the value of two cells
    By Abhi1687 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2013, 12:29 PM
  4. Replies: 9
    Last Post: 01-04-2013, 09:56 AM
  5. Merge cells in a column based on cells highlighted in other column
    By nileshrg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2011, 03:22 AM
  6. Populate a 2-column list based on highlighted cells
    By Pergo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-02-2011, 11:28 AM
  7. [SOLVED] how to filter out highlighted cells
    By grlong in forum Excel General
    Replies: 2
    Last Post: 04-26-2006, 05:20 PM

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