I am trying to sum every third cell of a column in a worksheet. The value of the cells are determined by a formula based on the value of the cell directly above, which in turn gets its value by calculating the cell above it:
For each column:
Row 1: User Input
Row 2: Calculated Value from Row1
Row 3: Calculated Value from Row2
The cell formulas are as follows, using R8, R9 & R10 as reference:
[R7 = 90000.00, Calculated]; [E8 = 0.0, User Input]
[User input] = 0.15
=IF(R8<>"",R$7/(R8/100),"") = 60000000
=IF(R8<>"",$E8*$D$6*1000*R8/100,"") = 0 [Because E8 = 0]
This sequence is repeated several times down the spreadsheet, hence why I need to sum every third row. Now honestly this makes it hell to work with, but I didn't design it and I don't have time to redesign it.
So here is the problem: My code just stops dead in its calculation at the highlighted line with no message. The cell then displays #VALUE!
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
For each column:
Row 1: User Input
Row 2: Calculated Value from Row1
Row 3: Calculated Value from Row2
The cell formulas are as follows, using R8, R9 & R10 as reference:
[R7 = 90000.00, Calculated]; [E8 = 0.0, User Input]
[User input] = 0.15
=IF(R8<>"",R$7/(R8/100),"") = 60000000
=IF(R8<>"",$E8*$D$6*1000*R8/100,"") = 0 [Because E8 = 0]
This sequence is repeated several times down the spreadsheet, hence why I need to sum every third row. Now honestly this makes it hell to work with, but I didn't design it and I don't have time to redesign it.
So here is the problem: My code just stops dead in its calculation at the highlighted line with no message. The cell then displays #VALUE!
Code:
Function GetSum(Column As String) As Double
Dim intLastRow As Integer
Dim G As Integer
Dim Col As Integer
With Worksheets("Product Formulas")
intLastRow = GetLastRow(wkSht:=ActiveSheet)
Col = GetColumnNumber(Column) 'Converts base 26 number system to base 10
For G = 10 To intLastRow Step 3
[highlight]GetSum = CDbl(.cell(G, Col).Value)[/highlight]
Next G
End With
End Function
At code failure:
Column = "O", GetSum = 0, intLastRow = 125, G = 10, Col = 15
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]