+ Reply to Thread
Results 1 to 13 of 13

VBA: Conditional Formatting rows when any cell in row has something in it

  1. #1
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    VBA: Conditional Formatting rows when any cell in row has something in it

    Hi

    In the attached worksheet the data is dragged and dropped from (say) row 80 up to a row in the Input columns above it. (NOTE The data has already been distributed in the attached sheet). As the range for the data covers columns F:AS (so some columns will be off screen) I want the full row the data is dropped in to change colour to warn me that data is in (say) Input 1 row 8 so I don't put anything else in row 8 in other Input columns.

    I have tried various ISBLSNK, ISNOTBLANK, COUNTA($F5:$AS5)>0 etc, but I can only get either the whole selection (F5:AS79) to be highlighted or none of it.

    (I don't know if dragging and dropping has an effect on the Conditional formatting)

    Any ideas please?

    Thanks

    Frankie
    Attached Files Attached Files
    Last edited by Frankie_The_Flyer; 04-05-2021 at 07:08 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Conditional Formatting rows when any cell in row has something in it

    Try:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Conditional Formatting rows when any cell in row has something in it

    Thanks for the response protonLeah.

    I added in the other input columns to the code you've suggested and made the "Apples to" cell in the condition $F5:$AS200. However, the whole table down to row 84 colours in although there is no data entered from row 70 downwards.
    When I go back to the condition the "Applies To" field has =$F$5:$AS$66,$F$69:$AS$200,$F$67:$AA$68,$AD$67:$AS$68 in it.

    Also, if I move (drag & Drop) data from one row to another, it just leaves the cells the data has come from with no format but the rest of the row remains formatted in the selected colour.

    There are no other conditions in the sheet so I'm a bit lost as to what's going on.

    Any ideas please??

    Revised sheet with the complete code and the extended format code attached.

    Frankie
    Attached Files Attached Files

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Conditional Formatting rows when any cell in row has something in it

    (I don't know if dragging and dropping has an effect on the Conditional formatting)
    Yes, it does. A simple drag and drop operation copies and pastes everything, including formatting options. However, that shouldn't matter if the rule is set up correctly.

    I don't understand the logic behind the formula in the Word document: why are you dividing the row into segments that are adjacent to each other? Why not just define the whole row? From your description, you want the whole row to highlight if anything appears in it anywhere.

    Not sure I'm confident that I understand what you want to achieve.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Conditional Formatting rows when any cell in row has something in it

    The problem is because of formulas.

    Remove the existing CF.
    Select $F$5:$AS$200
    Formula for CF is

    =COUNTIF($F5:$AS5,"?*")>0
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  6. #6
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Conditional Formatting rows when any cell in row has something in it

    Hi AliGW

    The formula I provided is an extension of the one from protonLeah. (Thought I'd give it a go!!).

    The response from kvsrinivasamurthy is doing what I'm after; highlighting a whole row between F & AS if any of the cells in that row has data in them.

    I now understand that the issue I have is about the drag dropping. It all works fine until I need to drag about during the sorting.
    EXAMPLE: If I move the data in Input 2 Row 10 down to Input 2 Row 15, Row 10 drops the formatting (all good!), but Input 2 Row 15 loses formatting (the rest of the row remains formatted). If I then move the data in Input 2 Row 15 back to Row 10 the Input 2 Row 15 cells stay un-formatted.

    I wonder if I need to go to VBA and format when the cell info changes?

    Ho Hum! Back to the drawing board!!

    Thanks

    Frankie

  7. #7
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Conditional Formatting rows when any cell in row has something in it

    Thanks for the response kvsrinivasamurthy .Excellent work!!

    As per my response to AliGW, I now understand that the issue I have is about the drag dropping.

    Thanks again

    Frankie

    Frankie

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Conditional Formatting rows when any cell in row has something in it

    Given the changes you want to continue to make, VBA might be the better option here. Someone will be able to suggest some code.

  9. #9
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Conditional Formatting rows when any cell in row has something in it

    I’ll post on the vba pages thanks Ali

  10. #10
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Conditional Formatting rows when any cell in row has something in it

    No - I'll move this thread. As you know, duplicate queries are not allowed.

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: VBA: Conditional Formatting rows when any cell in row has something in it

    Here is the VBA code for worksheet event for "Test 1" sheet.
    Drag and drop will not effect the CF. The code takes care of it.

    Worksheetevent

    To paste the code
    Right click on Sheet tab --> view code
    Visual Basic (VB) window opens.
    Paste the code
    Close the VB window.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: VBA: Conditional Formatting rows when any cell in row has something in it

    Wow! Quick response! Thanks kvsrinivasamurthy. Much appreciated.

  13. #13
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: VBA: Conditional Formatting rows when any cell in row has something in it

    Pl mark the thread solved.

+ 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. conditional formatting rows with various cell values
    By jjpcpanama in forum Excel General
    Replies: 4
    Last Post: 03-20-2020, 10:12 PM
  2. conditional formatting rows when cell values change every row
    By jjpcpanama in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-27-2018, 01:03 AM
  3. [SOLVED] conditional formatting based on other cell (over multiple Rows & Column)
    By pipsmultan in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2015, 03:50 AM
  4. Replies: 7
    Last Post: 07-07-2009, 08:32 AM
  5. Conditional Formatting - Highlight Rows if a cell contains text
    By crepe in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-13-2007, 08:25 PM
  6. Conditional Formatting 4+ conditions, format rows based on cell
    By nockam in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-12-2006, 06:12 PM
  7. [SOLVED] conditional formatting of entire rows:value of 1 cell
    By Mike in forum Excel General
    Replies: 1
    Last Post: 05-17-2006, 09:40 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