+ Reply to Thread
Results 1 to 8 of 8

Macro Help: IF A1 bigger than B1, color

  1. #1
    Registered User
    Join Date
    04-15-2019
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    4

    Question Macro Help: IF A1 bigger than B1, color

    Hello, I often use excel at work to compare classroom seat counts and think I could use a macro to make the job move quicker. I have the data pulled in like so:
    seats.PNG
    I would like to run a macro that will compare column H and J and color the cells in if H is a larger number than J. For instance, in this image, I would need row 7 (or even any single cell in row 7) to change color to signify that there are more requests than available seats. If anyone can help me build up some VBA, or point me in a good direction to start building this macro myself, I would really appreciate it. I only recently started using macros at all and all my coding background begins and stops with HTML

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Macro Help: IF A1 bigger than B1, color

    Welcome to the forum,

    Does it have to be a macro ?
    Maybe just ordinary conditional formatting ?

  3. #3
    Registered User
    Join Date
    04-15-2019
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Macro Help: IF A1 bigger than B1, color

    Thanks!
    If something other than a macro would work for it, I'm game. It just has to be repeatable across multiple workbooks and different datasets, is the only thing. I know that this is the Macro Help forum, but would you be able to give me an idea of how to set up a specific conditional formatting for this purpose?

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Macro Help: IF A1 bigger than B1, color

    Please Login or Register  to view this content.

    Frankly, writing this was quicker than conditional formatting.

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Macro Help: IF A1 bigger than B1, color

    Quote Originally Posted by Antiq View Post
    ... If something other than a macro would work for it ...
    Select the appropriate range in the 'H' column
    Select the conditional formatting icon
    Select New Rule
    Select Use a formula to determine which cells to format
    Enter a formula in the field =$H2>$J2
    Select the appropriate formatting

    A small guide:
    https://support.office.com/en-ie/art...b-f1951ff89d7f

  6. #6
    Registered User
    Join Date
    04-15-2019
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Macro Help: IF A1 bigger than B1, color

    Quote Originally Posted by BellyGas View Post
    ...Frankly, writing this was quicker than conditional formatting.
    Sorry for the beginner response but I can't get this code to work for me. I get a compile error

    Quote Originally Posted by porucha vevrku View Post
    Select the appropriate range in the 'H' column..
    Is there a way to get this to work for more than just the first selected cells? I've tried (for instance) "=$H>$J" and other variations and cannot quite get it to work for me.

    I really appreciate both responses. Apologies for the newbie questions

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Macro Help: IF A1 bigger than B1, color

    Quote Originally Posted by Antiq View Post
    Is there a way to get this to work for more than just the first selected cells?
    Yes of course, first select more than one cell and then as above (=$H2>$J2)

    Edit:

    or use the format painter
    Last edited by mjr veverka; 04-16-2019 at 04:13 PM.

  8. #8
    Registered User
    Join Date
    04-15-2019
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Macro Help: IF A1 bigger than B1, color

    Quote Originally Posted by porucha vevrku View Post
    ...or use the format painter
    Whoops, completely forgot about the format painter. That works. Thanks so much!

+ 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: 2
    Last Post: 04-22-2015, 03:42 PM
  2. Bigger macro cut down into steps.
    By rdelosh74 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2014, 11:51 AM
  3. [SOLVED] For all cells with font size bigger than 9, make that cell bold and color white
    By jasondu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2012, 02:18 PM
  4. Make a macro bigger than 64k
    By unolax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2009, 05:48 PM
  5. changing color of values bigger or smaller than target
    By Fedde in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 03-27-2006, 08:28 AM
  6. Replies: 2
    Last Post: 03-14-2006, 02:04 AM
  7. [SOLVED] Workbook Bigger and Bigger
    By Ye Yint Win in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 09:05 AM

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