I wrote some code to automatically update cell formulas based on the current month. I have 6 sheets in total (REPORT1- REPORT6) that need to be updated. The cells are different in each sheet. What would be the best way to optimize this code so I can make quick changes for each sheet?
Code:
Sub Month()
If CurrentMonth = July Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(R9:W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(R38:W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(R75:W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
ElseIf CurrentMonth = August Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(S9:W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(S38:W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(S75:W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
ElseIf CurrentMonth = September Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(T9:W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(T38:W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(T75:W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
ElseIf CurrentMonth = October Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(U9:W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(U38:W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(U75:W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
ElseIf CurrentMonth = November Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(V9:W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(V38:W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(V75:W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
ElseIf CurrentMonth = December Then
Worksheets("REPORT1").Range("X9").Formula = "=SUM(W9)"
Worksheets("REPORT1").Range("X9:X31").FillDown
Worksheets("REPORT1").Range("X38").Formula = "=SUM(W38)"
Worksheets("REPORT1").Range("X38:X41").FillDown
Worksheets("REPORT1").Range("X75").Formula = "=SUM(W75)"
Worksheets("REPORT1").Range("X75:X97").FillDown
End If
End Sub