Hi, I wonder whether someone can help me please.
I'm trying to put together a small script (below) to format sheets within a given array.
Sub MonthlyFormat()
Dim LastRow As Long
Dim ws As Worksheet
Const StartRow As Long = 5
For Each ws In Worksheets(Array("Monthly Direct", "Monthly Enhancements", "Monthly Indirect", "Monthly Overheads", "Monthly Projects"))
With ws.Range("B2")
.Value = "Monthly Actuals Used"
End With
With ws.Range("B3")
.Value = Evaluate("EoMonth(Today(), -2) + 1")
.NumberFormat = "mmm yy"
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 37
With .Font
.Name = "Lucida Sans"
.Bold = True
.Size = 10
End With
End With
With ws.Range("B2, B5, G5")
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 11
With .Font
.Name = "Lucida Sans"
.Bold = True
.Size = 11
.ColorIndex = 2
End With
End With
If ws.Value = Array("Monthly Direct", "Monthly Indirect", "Monthly Overheads") Then
With ws.Range("B7:D7, G7:K7")
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 37
With .Font
.Name = "Lucida Sans"
.Bold = True
.Size = 10
End With
End With
End Sub
The problem I'm having lies with this section of code:
If ws.Value = Array("Monthly Direct", "Monthly Indirect", "Monthly Overheads") Then
With ws.Range("B7:D7, G7:K7")
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 37
With .Font
.Name = "Lucida Sans"
.Bold = True
.Size = 10
End With
End With
As you can see, I'm trying to apply a certain set of formatting just to three of the sheets from the original array created at the beginning of the script, but I've clearly made an error because when I run this, I receive an error message.
I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.
Many thanks and regards
Bookmarks