Inserting a formula macro

DTSCWPT

New Member
Joined
May 29, 2018
Messages
1
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.

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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top