+ Reply to Thread
Results 1 to 7 of 7

Highlighting Cells using VBA (?)

  1. #1
    Registered User
    Join Date
    06-29-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2016
    Posts
    75

    Highlighting Cells using VBA (?)

    Hi guys,

    I need a VBA macro (activated using a clickable button) that will highlight a cell in a column if it is for the right date. So, a user will enter 08/07/2012 in cell A1, the macro will search for that date from a list of dates in column B, and will highlight the perpendicular cell value in column C. Can anyone help out? Sort of like a Vlookup + conditional formatting.

    Thanks!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Highlighting Cells using VBA (?)

    Why not just use Conditional Formatting?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-29-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2016
    Posts
    75

    Re: Highlighting Cells using VBA (?)

    That would work fine, I've never done conditional formatting w/a vlookup, can you explain further?

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Highlighting Cells using VBA (?)

    Select your range (i.e. B2:B5000)
    Conditional Formatting>New Rule> Use Formula
    =AND($B2=$A$1, ISNUMBER($B2))
    Does that work for you? I added the ISNUMBER part in case A1 is blank, it doesn't highlight all your blank cells

    ---------- Post added at 11:32 AM ---------- Previous post was at 11:30 AM ----------

    Oops, didn't see the part about Col C is what you want highlighted. You say Perpendicular. I assume you want the cell in the same row as the date in B.

    As above, except initially select the range in Col C, not B
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    06-29-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2016
    Posts
    75

    Re: Highlighting Cells using VBA (?)

    The issue is that I'm not matching the value in A1 with the values in column B. I'm matching the value in A1 (a date) with the values in column C, and then highlighting the perpendicular cell in column B. So, if A1 is 08/08/2012, and C5 is 08/08/2012, then B5 will be highlighted. Does that make sense?

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Highlighting Cells using VBA (?)

    Okay, I got it backwards (or sideways)
    Select range in Column B (i.e. B2:B2000)
    Conditional Formatting>New Rule> Use Formula
    =AND($C2=$A$1, ISNUMBER($C2))
    That will do what you are asking for.

  7. #7
    Registered User
    Join Date
    06-29-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2016
    Posts
    75

    Re: Highlighting Cells using VBA (?)

    Worked like a charm! Thanks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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