Excel Heiarchy and Highlight rows where certain data lies
This has a Mod statement in it that checks to see if the range is divisible
by four. If not it will exit the sub without executing the color scheme.
You can delete that line if you do not want the range to be exactly
divisible by four. I used the color index for red, green, blue and yellow
in the myArr array. You can change those to suit your purposes.
Sub fourColr()
Dim sh As Worksheet, rng As Range, myArr As Variant
Set sh = ActiveSheet
Set rng = Range("A1:A20") '<<<Set actual range
x = rng.Rows.Count
If x Mod 4 0 Then Exit Sub '<<<Dele this line if not desired
myArr = Array(3, 4, 5, 6) '<<<Change ColorIndex here
For i = 1 To x Step 4
If i < 5 Then
y = 1
Else
y = i
End If
z = 0
Do Until y = i + 4
sh.Rows(Cells(y, 1).Row).Interior.ColorIndex = myArr(z)
y = y + 1
z = z + 1
Loop
Next
End Sub
"BZeyger" wrote in message
...
Hello,
I am working on a macro and I do know how to go about it. I am just
getting
started with macro's.
I have an excel sheet that is laid out as a heiarchy chart.
Example:
A B C D
Bob
Gym
13 Years
Senior
I would like to highlight the rows that contain data in COL A one Color,
The
rows that contain data in COL B another color, etc.
How can this be coded?
|