Hi all,
I'm trying to write a bit of code that sums the value of a particular cell (in this case D4) in each of the worksheets in the application and returns the answer in a msgbox.
I've gotten this far but it doesn't work, any ideas?
Sub sumofD4()
Dim sumofD4()
Dim w As Integer
Dim i As Integer
Dim sum As Integer
sum = 0
w = Worksheets.Count
ReDim sumofD4(1 To w)
For i = LBound(sumofD4) To UBound(sumofD4)
sumofD4(i) = Worksheets(i).Range("D4").Value
Next i
For Each sumofD4(i) In Selection
sum = sum + sumofD4(i)
Next sumofD4(i)
MsgBox (i)
End Sub
Thanks in advace Plasmar8
I'm trying to write a bit of code that sums the value of a particular cell (in this case D4) in each of the worksheets in the application and returns the answer in a msgbox.
I've gotten this far but it doesn't work, any ideas?
Sub sumofD4()
Dim sumofD4()
Dim w As Integer
Dim i As Integer
Dim sum As Integer
sum = 0
w = Worksheets.Count
ReDim sumofD4(1 To w)
For i = LBound(sumofD4) To UBound(sumofD4)
sumofD4(i) = Worksheets(i).Range("D4").Value
Next i
For Each sumofD4(i) In Selection
sum = sum + sumofD4(i)
Next sumofD4(i)
MsgBox (i)
End Sub
Thanks in advace Plasmar8