I previously was working on a Macro to insert a formula to select a cell based on which month we were in. Because Excel would "break" if I made a formula long enough for every month in the year I have created 4 formulas for each financial quarter.
I am trying to create a macro that I can press that will "paste" the formula for quarter we are in, a macro for each quarter and if i can a macro that will run the correct macro using "todays date" to select the right macro.
However I have somehow broken my initial macro so it no longer runs let alone trying to get the second macro to run.
Below is "quarter one" i appreciate it is a mess, where I work they like to have a dashboard where you access everywhere else from hence the the first part of the code.
Apologies for how much of a mess it is.
I am trying to create a macro that I can press that will "paste" the formula for quarter we are in, a macro for each quarter and if i can a macro that will run the correct macro using "todays date" to select the right macro.
However I have somehow broken my initial macro so it no longer runs let alone trying to get the second macro to run.
Below is "quarter one" i appreciate it is a mess, where I work they like to have a dashboard where you access everywhere else from hence the the first part of the code.
Apologies for how much of a mess it is.
Code:
Sub Qone()
Application.ScreenUpdating = False
Sheets("Front Page").Select
Sheets("Pivots").Visible = True
Sheets("Front Page").Select
Sheets("Pivots").Select
Range("BP2").Formula = "=IF(AND($AL$1>=DATE(2018,3,1),$AL$1<=DATE(2018,3,31)),AP2, IF(AND($AL$1>=DATE(2018,4,1),$AL$1<=DATE(2018,4,31)), AP2,IF(AND($AL$1>=DATE(2018,5,1),$AL$1<=DATE(2018,5,31)), AP2,IF(AND($AL$1>=DATE(2018,6,1),$AL$1<=DATE(2018,6,31)),AR2, 'Change Quarter'))))"
Range("BP2").Select
Selection.AutoFill Destination:=Range("BP2:BP5"), Type:=xlFillDefault
Range("BP2:BP5").Select
Range("BP9").Select
ActiveCell.Formula = "=IF(AND($BP$1>=DATE(2018,3,1),$BP$1<=DATE(2018,3,31)),AP2, IF(AND($BP$1>=DATE(2018,4,1),$BP$1<=DATE(2018,4,31)), AR2,IF(AND($BP$1>=DATE(2018,5,1),$BP$1<=DATE(2018,5,31)), AT2,IF(AND($BP$1>=DATE(2018,6,1),$BP$1<=DATE(2018,6,31)),AV2, 'Change Quater'))))"
Range("BP9").Select
Selection.AutoFill Destination:=Range("BP9:BP13"), Type:=xlFillDefault
Range("BP9:BP13").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Front Page").Select
End Sub