Calculate sum as per record type
Here is my sample excel file data
How can I calculate sum of all CR and DR type records separately? Result should be
Total Debit = XXX Total Credit = XXX
Logic somthing like...
Dim debit; for each row in sheet1 if(data of C column == dr) debit = debit + data of D column end if end for print debit;
I am not very much familiar with Excel 2010 so not sure how to code this so please give me some basic steps also to achieve this.
You can get this using formula :
And if you want to get this using vba then you can write it like:
Dim debit, credit As Integer With Worksheets("Sheet1") For x = 1 To .Cells(Rows.Count, 3).End(xlUp).Row If UCase(.Cells(x, 3).Value) = "DR" Then debit = debit + .Cells(x, 4).Value Else If UCase(.Cells(x, 3).Value) = "CR" Then credit = credit + .Cells(x, 4).Value End If End If Next End With