+ Reply to Thread
Results 1 to 5 of 5

highlighting alternating blocks of rows based on cell text

  1. #1
    Registered User
    Join Date
    12-09-2017
    Location
    Ohio
    MS-Off Ver
    Excel 2013 (home/student)
    Posts
    60

    highlighting alternating blocks of rows based on cell text

    I would find it very helpful to have a general method to highlight alternating blocks of lines based on the text in one column (column A for purposes of illustration-see attached example). The sheet would be sorted by that column so that all rows with the same text (eg text1) would be together. Each time the text in column A changes, I want the background color to switch as illustrated so the blocks are easy to see.

    I imagine a little macro that examines each cell in column A and compares its text to the cell above. If the same, make the row fill the same as the row above, otherwise change the row fill to the alternative fill. I just don't know how to program that.

    Thanks in advance!

    Ohioruss
    Attached Files Attached Files
    Last edited by OhioRuss; 10-19-2022 at 09:54 AM. Reason: add attachment

  2. #2
    Forum Contributor
    Join Date
    08-12-2020
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 16
    Posts
    241

    Re: highlighting alternating blocks of rows based on cell text

    Hi Ohio, This solution does not use VBA but uses conditional formatting. Since you said the header1 text will be grouped together, I set up a formula to determine if the row above any given text has the same header, then assigning a number (in column K). Hide or move them as needed. Using conditional formatting you will need to assign a background color to each number. I set this up to repeat every 5 colors since I do not know how many text blocks you have, and every number-color needs to be set up individually.
    Drag down the formulas as far as you need.

    Good Luck,
    Squeaky
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-09-2017
    Location
    Ohio
    MS-Off Ver
    Excel 2013 (home/student)
    Posts
    60

    Re: highlighting alternating blocks of rows based on cell text

    Thanks Squeaky. I was able to get the column of numbers using your IF statement (1 and 2 were enough for me), which I then converted into actual numbers. I then temporarily sorted the spreadsheet by these numbers so the ones were together and the twos were together. I then manually colored them before putting the spreadsheet back to the original sequence. I found the conditional formatting unsatisfactory because it slowed down scrolling way too much (my sheet has 370,000 rows).

    Ohioruss

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: highlighting alternating blocks of rows based on cell text

    As for macro - try this one:

    Please Login or Register  to view this content.
    BTW. Please update your excel version in your profile info. For sure you are not processing 370 000 rows in Excel 2003 (neither in 97 )
    Best Regards,

    Kaper

  5. #5
    Registered User
    Join Date
    12-09-2017
    Location
    Ohio
    MS-Off Ver
    Excel 2013 (home/student)
    Posts
    60

    Re: highlighting alternating blocks of rows based on cell text

    Thanks Kaper. I will keep this in mind for the next time and maybe it will be useful to others as similar questions have come up before.

    I updated my profile as you suggested.

    Ohioruss

+ 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] Alternating blocks of text based on a value input from cells
    By SiMOKED in forum Excel General
    Replies: 5
    Last Post: 04-29-2020, 03:21 AM
  2. Formatting alternating blocks of rows
    By ngbc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2018, 08:26 AM
  3. Highlight alternating rows in groups based on cell text
    By DWNGKF in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-22-2017, 12:36 PM
  4. Highlighting alternating clusters of rows
    By CatalysTim in forum Excel General
    Replies: 7
    Last Post: 07-22-2015, 09:39 AM
  5. [SOLVED] Colour conditional formatting alternating blocks of rows
    By Deanomcbeano in forum Excel General
    Replies: 7
    Last Post: 10-03-2012, 01:48 PM
  6. Replies: 4
    Last Post: 05-31-2012, 01:49 PM
  7. Macro for Highlighting Rows based on Cell Value
    By ExcelNoobNJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2008, 08:08 AM

Tags for this Thread

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