View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Conditional Formationg Macro

Hi Gliimer,

To add,

Solution, change:

Set sh = ThisWorkbook.Sheets("fp12m")


to:

Set sh = ActiveWorkbook.Sheets("fp12m")


Or, alternatively, leave the code unchanged and move it to a standard module
in the workbook which houses the "fp12m" worksheet.

As a general rule of thumb, if code is to be used exclusively with a given
workbook, store the code with the workbook.

---
Regards,
Norman



"Norman Jones" wrote in message
...

Hi Glimmer,

does not quite work - did i go wrong? - I get the error, run-time error
9, subscript out of range.


At a guess, this is because, you have not put the code into the workbook
which houses the "fp12m" sheet.

Solution, change:

Set sh = ThisWorkbook.Sheets("fp12m")


to:

Set sh = ActiveWorkbook.Sheets("fp12m")


If this is not the problem, then check that the fp12m worksheet exists
and that its name is spelled correctly - also look for leading or trailing
spaces!


---
Regards,
Norman



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