ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,738
- Office Version
- 2007
- Platform
- Windows
Morning,
I am currently using this code supplied below but i overlooked something when i was applying the code etc.
The code takes the current month and enters it into cell B1 on several worksheets within the same workbook.
The part i overlooked was that on the 1st day of the month when i transfer all the sheets data by using the Copy To Summary Sheet button it obviously shows the current month & in this case "September" in cell B1 where all the values on the sheet are for the previous month "August"
So can you advise a work around or advise me please.
I am currently using this code supplied below but i overlooked something when i was applying the code etc.
The code takes the current month and enters it into cell B1 on several worksheets within the same workbook.
The part i overlooked was that on the 1st day of the month when i transfer all the sheets data by using the Copy To Summary Sheet button it obviously shows the current month & in this case "September" in cell B1 where all the values on the sheet are for the previous month "August"
So can you advise a work around or advise me please.
Code:
Sub AddMonth()
Dim arr, i As Long
arr = Array("INCOME (1)", "INCOME (2)", "INCOME (3)", "EXPENSES (1)", "EXPENSES (2)", "EXPENSES (3)", "EXPENSES (4)", "EXPENSES (5)", "EXPENSES (6)", "EXPENSES (7)", "EXPENSES (8)")
For i = LBound(arr) To UBound(arr)
With Sheets(arr(i))
.Range("B1") = UCase(Format(Now, "mmmm"))
.Range("B2") = Year(Now)
With .Range("B1:B2")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
With .Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 11
End With
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End With
End With
Next
With Sheets("MILEAGE")
.Range("B1:C1") = UCase(Format(Now, "mmmm"))
.Range("D1") = Year(Now)
With .Range("B1:D1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
With .Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 24
End With
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End With
End With
End Sub