All pastes #410517 Raw Edit

Anonymous

public text v1 · immutable
#410517 ·published 2007-03-26 13:33 UTC
rendered paste body
An example of the rows im trying to add:

Num           Amount
---------------------------
4757          50.00
2874          70.00
3956          50.00
7887          80.00
7887          25.00
9892          35.00

i need it to add up the amounts from rows with like Num values.
and debug.print them row by row

what i had so far....

           cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source=" & strInputFileName & ";" & _
                    "Extended Properties=""Excel 8.0;HDR=Yes"";"
           rst.Open "SELECT * FROM [Sheet1$] WHERE [Type] = 'Bill' ;", cnn, adOpenStatic, adLockReadOnly
           rst.MoveFirst
           Do

If rst![Amount] <> "Null" Then
    amt_2 = Val(rst![Amount])
    
    If num_2 = num_1 Then
        amt_2 = amt_1 + amt_2
        End If
    If num_2 <> num_1 Then
        Debug.Print amt_2
        End If
    If IsNull(num_1) Then
        num_1 = rst![Num]
        num_2 = rst![Num]
        amt_1 = rst![Amount]
        End If
    
    End If
    

    rst.MoveNext