I'm trying to create a macro that publishes the past 3 months worth of data with a single run. To do this, I need to update a formula, refresh the worksheet a few times, run a macro to publish the values (addrow
), and repeat for the past 3 mo. However my VBA code doesn't update the formula in cell G2 - due to this I'm not sure if it is refreshing the sheet (since only after the formula is updated will the values on the worksheet change after a refresh). Would really appreciate any insight on how to solve this.
My current output is just a repeat of the same days values over and over again.
Worksheets("Historical Close").Activate
Range("G2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-60"
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
Call addrow
Worksheets("Historical Close").Activate
Range("G2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-59"
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
Call addrow
Worksheets("Historical Close").Activate
Range("G2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-58"
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
Call addrow
Worksheets("Historical Close").Activate
Range("G2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-57"
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
ActiveSheet.Calculate
Call addrow