View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gee-off Gee-off is offline
external usenet poster
 
Posts: 19
Default Automatically Format Range of Cells

Steve,

How do I incorporate this code, written below, into my spreadsheet? I have
never actually input code such as that into a spreadsheet before. Do you
just type it into the cell, or is there a different procedure for this?
Thanks.

"Steve Yandl" wrote:

Nigel,

See if something like this subroutine will do what you want.

Sub Decorate()
Dim rngB As Range
Dim rngTemp As Range
Set rngB = Sheets(1).UsedRange.Columns("B:B")
For R = 1 To rngB.Rows.Count
If Sheets(1).Cells(R, 2).Value = "Category" Then
Set rngTemp = Sheets(1).Cells(R, 2).Range("A1:O1")
rngTemp.Font.Bold = True
With rngTemp.Interior
..ColorIndex = 41
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
End With
End If
Next R
End Sub


Steve
"Nigel" wrote in message
...

Thanks, but this does not work for what I want, the word category could be
in any row (although it will only be in Column B), plus I want the row
where
the word category to get the new formating, so the first time I run it the
word could be in rows 2,17 and 23. The next time I run it the word could
be
in 4,6,9,14,23 etc.

I need to do a find of the word category and then format columns B to P
for
that row


"Leith Ross" wrote:


Hello Nigel,

You can make those changes automatically by using Conditional
Formatting. Select the Range of cells you want and go to Format on the
Menu and select *Conditional Formatting...* You can implement upto 3
conditional formats.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:
http://www.excelforum.com/showthread...hreadid=490440