+ Reply to Thread
Results 1 to 14 of 14

How to conditionally format a dynamic range

  1. #1
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    How to conditionally format a dynamic range

    Hey Forum,

    I am wondering how to conditionally format a range which may expand vertically or horizontally at any point, if more line items are added.
    The Conditional format is essentially blocking out any Blank cell and turning it grey (see example)
    I would like the conditional format to make all the cells that are empty, grey where:
    For rows: Where there is text on the preceding row, add + 1 to the conditional format so it formats the next row as grey.
    For columns: Where there is text on the preceding column, add + 1 to the conditional format so it formats the next column as grey.

    Kind Regards,

    Julian

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    For 365 or 2016?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    I use 365 at work so a 365 solution would be fine!
    2016 would be interesting to know but not required at all.
    I'm assuming the 2016 solution would be something around OFFSET() and COLUMNS() and ROWS().

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    If 2016 is not going to be used, then it may well be easier with 365.

  5. #5
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    I have no problem with that!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    I'm not at all sure it will be possible without VBA - let's see what others come up with.

  7. #7
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    Hi Ali, I actually think that the range automatically updates when I add in new rows or columns.
    If I manually set up the range to begin with for the conditional format to apply to initially, then this range auto expands depending on if I add columns or rows to it.
    So Excel has mostly SOLVED it.
    The only thing which I was wondering if it was possible was a formula that would make it so I wouldn't have to manually select the range at the start.
    I might just be trying to escape laziness though...

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    I think you are trying to find laziness, not escape it, as are we all!

    As my other half often says, "technology is created by lazy people".

    OK - I am going to see what I've missed in your workbook.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    OK - I've had a look. Where is this range that automatically updates? I cannot find such a range either in your CF rules or in Named Ranges.

  10. #10
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    I haven't got it in the example. But what I'm saying is that when you add a new row or column INSIDE (it has to be inside otherwise the range that CF says doesn't expand (another problem!!!)) then the CF Range automatically includes that, but only if it is inside of the predefined CF range.
    I'm probably not making much sense.
    Check Sheet 2

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2501 (Windows 11 24H2 64-bit)
    Posts
    89,014

    Re: How to conditionally format a dynamic range

    Yes, I see that.

  12. #12
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    This might be a VBA only if there is no response. Funny because I thought this would be a simple fix, but apparently not so!
    I will go manual for the time being.

  13. #13
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    536

    Re: How to conditionally format a dynamic range

    VBA has a ModifyAppliesToRange method which can programatically change what cells are to have a conditional formatting rule applied.

    The attached workbook has code included in the WorksheetChange event procedure which will apply an existing CF rule to the 'UsedRange' of the worksheet. It could be tweaked so that maybe a few rows or columns are not included.

    The code doesn't have any error checking and assumes that everything starting in A1 to wherever the last piece of data is located is to be formatted. Think of it as just a prototype to get started on and. The code is as follows:

    Please Login or Register  to view this content.
    If you add anything to a cell (or delete something from a last row or column) , the CF rule will automatically update to include the new rows and columns to the new cell.
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  14. #14
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    275

    Re: How to conditionally format a dynamic range

    Late reply, but thanks deadlyduck, that works exactly as I wanted and as if by magic, auto updates! I changed the +1 to +2 and put +2 for both row and column arguments and it works great!
    Thank you very much, I'll have to dabble with VBA in the future!

+ 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] Trying to conditionally format columns based on dynamic cell values
    By LukeMac2 in forum Excel General
    Replies: 10
    Last Post: 08-28-2023, 01:18 AM
  2. Replies: 6
    Last Post: 07-21-2022, 07:03 AM
  3. [SOLVED] Conditionally format a range in Excel 2003?
    By Carson Dyle in forum Excel General
    Replies: 5
    Last Post: 11-09-2016, 06:46 PM
  4. VBA to Conditionally format date range on calendar
    By am_hawk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2014, 04:44 PM
  5. Need help for macro to conditionally format a selected range
    By smusyaju in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2014, 04:44 PM
  6. [SOLVED] Conditionally Format Dynamic Range
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2014, 12:43 PM
  7. [SOLVED] Vba code to conditionally format a specific range
    By kelwood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-29-2012, 10:14 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