Помните, всегда добавляйте Option Explicit
в самый верх вашего кода.Это заставит вас объявить все ваши переменные, что, в свою очередь, избавит вас от всевозможных неприятностей.
Вот как я бы это сделал
Sub addAcrossSheets()
Dim sht As Worksheet
Dim totalSum As Double
totalSum = 0 'initialize the sum
For Each sht In ThisWorkbook.Worksheets 'loop through the collection of worksheets
totalSum = totalSum + sht.Range("A4") 'update the sum
Next sht
Debug.Print totalSum 'the result is displayed in your immediate window
End Sub
Теперь вы можете захотетьисключить некоторые листы из суммы.Вы можете сделать это так:
For Each sht In ThisWorkbook.Worksheets 'loop through the collection of worksheets
If sht.Name <> "Something" And sht.Name <> "Something else" Then 'exclude worksheets from the sum
totalSum = totalSum + sht.Range("A4") 'update the sum
End If
Next sht