Hi, I would appreciate your advice on the following code. It might be very simple but I dont see it. Why it gives me an application or object defined error when I reach the underlined line in the code below?

Dim WS As Integer
    Dim WSCounter As Integer
    Dim WSPV As Long
    Dim SumPV As Long
    Dim Period As Range
    Dim TotalPeriods As Range
    
    WSCounter = Worksheets.Count - 1
    Set TotalPeriods = Range("A2", Range("A2").End(xlDown))
    
    For Each Period In TotalPeriods
        For WS = 1 To WSCounter
            WSPV = WorksheetFunction.Sum(Worksheets(WS).Range(Period))
            SumPV = SumPV + WSPV
        Next WS
        Worksheets("Sheet1").Range("A2") = SumPV
    Next Period

Thank you in advance for the help.