Alternate Cell shading

jlangella36

New Member
Joined
Nov 18, 2005
Messages
2
Is there an easy way to shade every other cell based on the data within the cell.

for example.

1 - shade grey
1 - shade grey
1 - shade grey
1 - shade grey
2
2
3 - shade grey
4
4
4
5 - shade grey
5 - shade grey
5 - shade grey
5 - shade grey
6
7 - shade grey
8

this needs to be done for thousands of records and will be sort on the name, it wont be numbers, i just used that as an example, there will be at least 100 unique records, so would be hard to program.

thanks,

Jeff
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Ben Dover

New Member
Joined
Sep 3, 2004
Messages
31
I have not used it much but the free ASAP add in has a few shading tools that are easy to use

Ben
 

Brian from Maui

MrExcel MVP
Joined
Feb 16, 2002
Messages
8,459
If you want every other row shaded using Conditional Formatting, highlight your range, go to Format/Conditional Formatting and Formula is, condition 1

=MOD(ROW(),2)=0

condition 2

=MOD(ROW(),2)=1
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,348
try this
Code:
Sub yui()
r = 2
1:
Do While Not IsEmpty(Cells(r, 1))
Do While Cells(r, 1) = Cells(r + 1, 1)
Cells(r, 1).Interior.ColorIndex = 15
r = r + 1
Loop
Cells(r, 1).Interior.ColorIndex = 15
r = r + 1

Do While Cells(r, 1) = Cells(r + 1, 1)
Cells(r, 1).Interior.ColorIndex = xlNone
r = r + 1
Loop
Cells(r, 1).Interior.ColorIndex = xlNone
r = r + 1
GoTo 1
Loop

End Sub
 

jlangella36

New Member
Joined
Nov 18, 2005
Messages
2
thanks pcc,

that worked great, it came up with a runtime error, but overall it worked.

thanks again,

Jeff
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,431
Office Version
  1. 365
Platform
  1. Windows
jlangella36

Welcome to the Mr Excel board!

For a Conditional Formatting solution as shown below.

1. Select A2:A??
2. Format|Conditional Formatting...|Formula Is:
=MOD(SUMPRODUCT(--(A$1:A1<>A$2:A2)),2)
3. Click Format... and choose colour
4. OK, OK
Mr Excel 05 11 20.xls
ABCD
1Fred
2Fred
3Jan
4Jan
5Jan
6Sam
7Sam
8Ann
9Bill
10Bill
11Bill
12Sue
13Sue
14
Conditional Format
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,546
Messages
5,838,011
Members
430,526
Latest member
NiceGuyWithExcel2007

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
Top