Custom Highlighting Macro

petegrant89

New Member
Joined
Jun 28, 2011
Messages
21
Hello,

I have a spreadsheet with a long list of portfolios, most containing multiple rows with the same portfolio name. I need to highlight every other portfolio grouping an alternating color.

For instance, If I have as follows:

Portfolio1
Portfolio1
Portfolio1
Portfolio1
Portfolio2
Portfolio2
Portfolio3
Portfolio3
Portfolio3
Portfolio3
Portfolio4

I need portfolio 1's entire row to highlight blue, Portfolio 2's entire row to stay white, Portfolio 3's entire row to highlight blue, and Portfolio 4's entire row to stay white; and so on and so forth for the entire document.

I haven't the slightest idea how to start this one, so any help would be greatly appreciated.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
One way is to use a "helper" column and use conditional formatting.

For example, let's say that your data begins in A1.
In cell B1, enter "1" (without the quotes).
Then in cell B2, enter this formula (which is essentially a cumulative group counter):
=IF(A2=A1,B1,B1+1)
Copy that formula down column B for all rows.

Now, highlight your whole data range, select Conditional Formula and use this formula:
=MOD($A1,2)=1
and select the blue color fill formatting option.

That should do what you want!
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top