Hi! I have a problem with an error 13 (whatever that is) regarding a loop within VBA. My office is 2013.
I have a workbook with a group of sheets, named more or less like this:
DataSheet - Sheet1 - Sheet2 - Sheet3 - Sheet4 - Sheet5 - CALC - [and more sheets after CALC]
Between Sheet1 and Sheet5 I have a formula in each H55 cell (or Cells(55,8) to make some calculations and retrieve a decimal number (like 67.3). Some of this cells may get no value because the formula within H55 will only make the calculations if certain conditions are met. So, sometimes H55 may show a number in Sheet1 but maybe Sheet2 nothing will show in H55.
Now to the code. The code is to sum all the H55 values between Sheet1 and Sheet5 (from the second to the sixth)
Sub whatever()
Dim i as Byte 'this is for the Next For loop
Dim sumUp as Double 'I tried as double, variant, etc.
sumUp = 0 'this is to have just a starting value
For i = 2 to 6
sumUp = sumUp + Worksheets(i).Cells(55, 8).Value
Next i
Worksheets(CALC).Cells(43, 4).Value = sumUp
End Sub
And thats it! I get a debug error, error 13. Even if I put some if statement to ignore empty cells, the error will keep:
If Application.WorksheetFunction.CountA(Worksheets(i).Cells(55, 8)) > 0 Then [this is right before the sumUp = sumUp + etc]
Can you help me? Thanks!
Bookmarks