Thread: Shading Rows
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
briank briank is offline
external usenet poster
 
Posts: 31
Default Shading Rows

Thanks Tom. Your code works great.
Regards, Brian

"Tom Ogilvy" wrote:

Dim lastrow as Long, i as Long
lastrow = cells(rows.count,1).End(xlup)
for i = 1 to lastrow
if cells(i,"B").Value < 3 then
rows(i).Interior.ColorIndex = 3
elseif cells(i,"B").Value 10 then
rows(i).Interior.ColorIndex = 5
else
rows(i).Interior.ColorIndex = xlNone
end if
Next

--
Regards,
Tom Ogilvy

"briank" wrote in message
...
I would like a row shaded based upon one of two values in column B. The
number of rows will change from worksheet to worksheet and my preference

is
to use VBA as opposed to conditional formatting. Any suggestions?