Hi All,
I wrote a macro to read in inforamtion based on a certain criteria. The macro reads in the info and prints the info in a seperate sheet fine, but I can not figure out how to place a count or a sum on two data points. For example-
Criteria Age Amt
A 48 100
A 52 200
B 60 500
B 38 200
Is there a way to have the code automatically count how many ages right after criteria A and add the total after criteria A and then do the same for criteria B. The data is always changing and I don't want to put in sums on the sheet because the ranges can vary. Anyone have any ideas. I inserted the code- your critique would be appreciated. thanks Again.
Sub read_data(sec() As Nostro)
'read in info from nostro detail sheet
Dim i As Integer, num_record As Integer
Sheets("Nostro Detail"
.Select
i = 2
num_record = 0
Do While (Cells(i, 1).Value <> ""
If find_sec(Cells(i, 22).Value) Then
num_record = num_record + 1
ReDim Preserve sec(1 To num_record)
sec(num_record).critera = Cells(i, 22).Value
sec(num_record).age = Cells(i, 3).Value
sec(num_record).ccy = Cells(i, 11).Value
sec(num_record).ccy__amount = Cells(i, 10).Value
sec(num_record).new_spn = Cells(i, 5).Value
sec(num_record).nm_type = Cells(i, 13).Value
sec(num_record).sett_type = Cells(i, 16).Value
sec(num_record).vdate = Cells(i, 9).Value
Else
End If
i = i + 1
Loop
End Sub
Sub print_results(sec() As Nostro)
Dim i As Integer
Sheets("Sheet1"
.Select
For i = 1 To UBound(sec)
Cells(i + 1, 1).Value = sec(i).critera
Cells(i + 1, 2).Value = sec(i).age
Cells(i + 1, 3).Value = sec(i).amt
Next i
End Sub
I wrote a macro to read in inforamtion based on a certain criteria. The macro reads in the info and prints the info in a seperate sheet fine, but I can not figure out how to place a count or a sum on two data points. For example-
Criteria Age Amt
A 48 100
A 52 200
B 60 500
B 38 200
Is there a way to have the code automatically count how many ages right after criteria A and add the total after criteria A and then do the same for criteria B. The data is always changing and I don't want to put in sums on the sheet because the ranges can vary. Anyone have any ideas. I inserted the code- your critique would be appreciated. thanks Again.
Sub read_data(sec() As Nostro)
'read in info from nostro detail sheet
Dim i As Integer, num_record As Integer
Sheets("Nostro Detail"
i = 2
num_record = 0
Do While (Cells(i, 1).Value <> ""
If find_sec(Cells(i, 22).Value) Then
num_record = num_record + 1
ReDim Preserve sec(1 To num_record)
sec(num_record).critera = Cells(i, 22).Value
sec(num_record).age = Cells(i, 3).Value
sec(num_record).ccy = Cells(i, 11).Value
sec(num_record).ccy__amount = Cells(i, 10).Value
sec(num_record).new_spn = Cells(i, 5).Value
sec(num_record).nm_type = Cells(i, 13).Value
sec(num_record).sett_type = Cells(i, 16).Value
sec(num_record).vdate = Cells(i, 9).Value
Else
End If
i = i + 1
Loop
End Sub
Sub print_results(sec() As Nostro)
Dim i As Integer
Sheets("Sheet1"
For i = 1 To UBound(sec)
Cells(i + 1, 1).Value = sec(i).critera
Cells(i + 1, 2).Value = sec(i).age
Cells(i + 1, 3).Value = sec(i).amt
Next i
End Sub