Sub forEachWs()
Dim Ws As Worksheet
Windows("XYZSheet.xlsx").Activate
For Each Ws In ActiveWorkbook.Worksheets
Range("E1").Select
ActiveCell.FormulaR1C1 = "=SUM(C[-2])"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=(RC[-1]/R1C5)"
Range("D2").Select
Selection.Copy
Range("D2:D2450").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("D:D").Select
Range("D2").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Replace What:="0", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next Ws
End Sub
The code does not loop through the other tabs within the Sheets of Workbook "XYZSheet.xlsx" and I cannot seem to understand why.
The code in the middle from "Range(E1)" all the way to "ReplaceFormat:=False" are all through a recorded session with minor edits.
I don't fully understand VBA code apart from cycling through it with F8, so please go easy on me!
Thanks!