hey guys, I have the following code:
Function summation_interim()

Dim r As Range
Dim r2 As Range
Dim cur_firm As String
Dim start_firm As String
Dim firm_search_start_row As Long
Dim symb_result_row As Long
Dim accum_perc As Double
Dim accum_perc_result As Double

start_firm = Range("d13")

'FIND THE NON-BASELINE COMPANY
For Each r In Range("b13", Range("b13").End(xlDown))
    If Not Trim(r.Offset(0, 2)) = start_firm Then
        firm_search_start_row = r.Row
        Exit For
    End If
Next r

symb_result_row = 13

'THE 1st ITERATIONS START HERE
For Each r In Range("b13", "b" & CStr(firm_search_start_row - 1))

    cur_symb = Trim(r)
    cur_firm = Trim(r.Offset(0, 2))
    accum_perc = r.Offset(0, 1)
        
        For Each r2 In Range("b" & CStr(firm_search_start_row - 1), Range("b" & CStr(firm_search_start_row - 1)).End(xlDown))
            If Trim(r2) = cur_symb Then
                accum_perc = accum_perc + r2.Offset(0, 1)
                Exit For
            End If
        Next r2
        
            accum_perc_result = accum_perc
            Range("h" & CStr(symb_result_row)) = cur_symb
            Range("i" & CStr(symb_result_row)) = accum_perc_result
            symb_result_row = symb_result_row + 1

Next r

'THE 2nd ITERATIONS START HERE
For Each r In Range("b" & CStr(firm_search_start_row), Range("b" & CStr(firm_search_start_row)).End(xlDown))

    cur_symb = Trim(r)
    cur_firm = Trim(r.Offset(0, 2))
    accum_perc = r.Offset(0, 1)
        
        For Each r2 In Range("b13", "b" & CStr(firm_search_start_row - 1))
            If Trim(r2) = cur_symb Then
                GoTo nextSymbol 'THIS SYMBOL HAS ALREADY BEEN DONE
            End If
        Next r2
        
            accum_perc_result = accum_perc
            Range("h" & CStr(symb_result_row)) = cur_symb
            Range("i" & CStr(symb_result_row)) = accum_perc_result
            symb_result_row = symb_result_row + 1

nextSymbol:
Next r

End Function
I'd like to turn this into an actual algorithm that makes sense rather than just issuing a bunch of iterating code blocks. can anyone help me with this? thanks.