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.
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