Can someone please help me understand why I cannot get this. I need this code to run through a undetermined amount of rows and filter them by a, b, or c then adds the filtered values together and posts the sum in another sheets cells. So if I had my data as: a = 4, b = 5, a = 6 then the other sheet would show a = 10 and b = 5 in total.
Thanks in advance for helping guys!
Thanks in advance for helping guys!
VBA Code:
Sub Test()
Dim A As Integer
Dim B As Integer
Dim C As Integer
A = 0
B = 0
C = 0
Do Until IsEmpty(Sheet2.Cells(i, 1))
i = 1
If Sheet2.Cells(i, 1) = "a" Then
A = A + Sheet2.Cells(i, 1)
Sheet1.Range("A2") = A
i = i + 1
ElseIf Sheet2.Cells(i, 1) = "b" Then
B = B + Sheet2.Cells(i, 1)
Sheet1.Range("B2") = B
i = i + 1
ElseIf Sheet2.Cells(i, 1) = "c" Then
C = C + Sheet2.Cells(i, 1)
Sheet1.Range("C2") = C
i = i + 1
End If
Loop
End Sub