Need Help Deciphering this Code

lexbung

New Member
Joined
Aug 4, 2017
Messages
5
Hello,

I just had to learn VBA for my internship this summer due to a project I had to do. The project is basically figuring out how a pre-built model works. Thanks to Google and previous questions/guides in this forum, I've been able to figure out the bulk of the model, except one Sub (below).

I understand the Sub itself will be out of context but I posted it to give context to the lines I don't understand (bolded and italicized).

What does it mean (or in general) when the code is "expression1()=expression1() + expression2"? I'm having trouble wording it for Google or the forum hence why I had to make a thread about it.

Some help would be appreciated.

Please and thanks.
Rich (BB code):
Sub CutEmLoose(Liabs As Range)Dim NumRows As Long, RowNum As Long, ModAmt As Double
Dim LiabAmts() As Double, LGDAmts() As Double, LossRates() As Double
Dim i As Long, ws As Worksheet
    
    Set ws = ActiveWorkbook.Worksheets("Liability Inputs")
    NumRows = Application.Max(Liabs.Columns(1))


ReDim LiabAmts(1 To NumRows)
ReDim LGDAmts(1 To NumRows)
ReDim LossRates(1 To NumRows)
    
    For i = 3 To Liabs.Rows.Count + 2
        RowNum = Liabs.Cells(i - 2, 1).Value
        ModAmt = Liabs.Cells(i - 2, 8).Value
        If Liabs.Cells(i - 2, 11).Value <> "" Then

LiabAmts(RowNum) = LiabAmts(RowNum) + ModAmt
If ModAmt > 0 Then LGDAmts(RowNum) = LGDAmts(RowNum) + (Liabs.Cells(i - 2, 11) * ModAmt)
If ModAmt > 0 Then LossRates(RowNum) = LossRates(RowNum) + (Liabs.Cells(i - 2, 12) * ModAmt)
       
 End If
    Next i
    For i = 3 To NumRows
        If LiabAmts(i) > 0 Then
            ws.Cells(i, 21).Value = LGDAmts(i) / LiabAmts(i)
            ws.Cells(i, 22).Value = LossRates(i) / LiabAmts(i)
        End If
    Next i
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,215,884
Messages
6,127,567
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top