Hey everyone, I am trying to run the following VBA for all sheets in my workbook but it is only processing the tab that is selected at the time the VBA starts. I suspect it is because I don't have it formatted properly since I recorded a macro to inform this VBA but I don't have enough experience to understand how it is formatted improperly. Any suggestions/help would be greatly appreciated!
VBA Code:
Sub PriorQuarterTotals ()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Columns("Q:Q").Select
Selection.Replace What:="#N/A", Replacement:="0", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").Select
Next ws
For Each ws In ActiveWorkbook.Worksheets
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=""***Prior Quarter Totals: $""&TEXT(ROUND(SUMIFS('[Inventory VBA.xlsm]2020 Q2 All'!R4C8:R60000C8,'[Inventory VBA.xlsm]2020 Q2 All'!R4C6:R60000C6,1,'[Inventory VBA.xlsm]2020 Q2 All'!R4C14:R60000C14,R4C14),2),""#,##0_ ;-#,##0 "")&""***"""
Range("E2").Select
Selection.Font.Bold = True
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=""***Prior Quarter Retail Totals: $""&TEXT(ROUND(SUMIFS('[Inventory VBA.xlsm]2020 Q2 All'!R4C8:R60000C8,'[Inventory VBA.xlsm]2020 Q2 All'!R4C6:R60000C6,1,'[Inventory VBA.xlsm]2020 Q2 All'!R4C14:R60000C14,R4C14),2),""#,##0_ ;-#,##0 "")&""***"""
Range("E2").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next ws
End Sub