chungtinhlak
01-14-2009, 09:55 AM
I have many calculation that I have to do. This is just a small example:
I have columns, A, C, and D as category. Column B is value. I want to say that if any cell column A = "whatever it is", then I wan to add the value for that same row in column B., I also need a way to count, if a certain condition matches, then count as 1 and add as it goes.
I tried this but it does not work.
Sub test()
Dim i As Long, y As Long, usedcell As Long
Dim checkrange As Range
usedcell = Application.WorksheetFunction.CountA(Range("A:A"))
For Each checkrange In Range("A1:A" & usedcell)
If checkrange = "Thaison" Then
i = checkrange
Range("C").Value = Range("B" & i).Value + Range("B" & i).Value
End If
Next
End Sub
I have columns, A, C, and D as category. Column B is value. I want to say that if any cell column A = "whatever it is", then I wan to add the value for that same row in column B., I also need a way to count, if a certain condition matches, then count as 1 and add as it goes.
I tried this but it does not work.
Sub test()
Dim i As Long, y As Long, usedcell As Long
Dim checkrange As Range
usedcell = Application.WorksheetFunction.CountA(Range("A:A"))
For Each checkrange In Range("A1:A" & usedcell)
If checkrange = "Thaison" Then
i = checkrange
Range("C").Value = Range("B" & i).Value + Range("B" & i).Value
End If
Next
End Sub