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
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

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,458
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,345
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
47,473
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,111
Messages
5,570,254
Members
412,313
Latest member
pauloalex
Top