Conditional Formationg Macro
Hi,
Probably failed because of the format of the cells in row 5.
The following, a variation which is a bit longer and less elegant, may work.
For months other than "June", change accordingly.
Sub Test()
Dim Col
'reset full range (exc. column header)
With Range("F6:BM265").Font
.Size = 10
.Bold = False
End With
'using column numbers e.g. A=1, B=2 etc
'F=6 BM=65
For Col = 6 To 65
If Cells(5, Col) = "June" Then
'highlight (exc. column header)
With Range(Cells(6, Col), Cells(265, Col)).Font
.Size = 12
.Bold = True
End With
End If
Next Col
End Sub
Don
wrote in message
oups.com...
does not quite work - did i go wrong? - I get the error, run-time error
9, subscript out of range.
Public Sub FormatJune()
Dim sh As Worksheet
Dim rng As Range
Dim rCell As Range
Set sh = ThisWorkbook.Sheets("fp12m")
Set rng = sh.Range("B5:BM5")
For Each rCell In rng.Cells
If Month(rCell.Value) = 6 Then
With rCell.Resize(sh.UsedRange.Rows.Count).Font
.Bold = True
.Size = 14
End With
End If
Next rCell
End Sub
|