Option Explicit
..........
..........
.........
'average five simmuations for a given stock
ArrayofChosenAssetsInvestment(i) = ((Simulation(1) + Simulation(2) + Simulation(3) + Simulation(4) + Simulation(5)) / 5)
End If
'output results to spreadsheet
Range("H2").Value = "Initial"
Range("H3").Value = "Final"
Range("H1").Offset(0, i).Value = ArrayOfChosenAssets(i)
Range("H2").Offset(0, i).Value = InvestmentInitialValue(i)
Range("H3").Offset(0, i).Value = ArrayofChosenAssetsInvestment(i)
Range("n2") = Range("i2").Value + Range("j2").Value + Range("k2").Value + Range("l2").Value + Range("m2").Value
Range("n3") = Range("i3").Value + Range("j3").Value + Range("k3").Value + Range("l3").Value + Range("m3").Value
Range("n4") = (Range("n3").Value - Range("n2").Value) / Range("n2").Value
Next i
'build final message
message = "Final Portfolio Values:" & vbNewLine & vbNewLine
If frmInput.ListBoxAsset1.Value = 0 Or frmInput.InvestAsset1.Value = 0 Then
message = message & ""
Else
message = message & Range("i1").Value & " had an initial value of: " & Format(Range("i2").Value, "currency") _
& " and a final value of: " & Format(Range("i3").Value, "currency") & vbNewLine
End If
If frmInput.ListBoxAsset2.Value = 0 Or frmInput.InvestAsset2.Value = 0 Then
message = message & ""
Else
message = message & Range("j1").Value & " had an initial value of: " & Format(Range("j2").Value, "currency") _
& " and a final value of: " & Format(Range("j3").Value, "currency") & vbNewLine
End If
If frmInput.ListBoxAsset3.Value = 0 Or frmInput.InvestAsset3.Value = 0 Then
message = message & ""
Else
message = message & Range("k1").Value & " had an initial value of: " & Format(Range("k2").Value, "currency") _
& " and a final value of: " & Format(Range("k3").Value, "currency") & vbNewLine
End If
If frmInput.ListBoxAsset4.Value = 0 Or frmInput.InvestAsset4.Value = 0 Then
message = message & ""
Else
message = message & Range("l1").Value & " had an initial value of: " & Format(Range("l2").Value, "currency") _
& " and a final value of: " & Format(Range("l3").Value, "currency") & vbNewLine
End If
If frmInput.ListBoxAsset5.Value = 0 Or frmInput.InvestAsset5.Value = 0 Then
message = message & "" & vbNewLine & vbNewLine
Else
message = message & Range("m1").Value & " had an initial value of: " & Format(Range("m2").Value, "currency") _
& " and a final value of: " & Format(Range("m3").Value, "currency") & vbNewLine & vbNewLine
End If
message = message & "Predicted Final Portfolio Value (after 10 years) = " & Format(Range("n3").Value, "currency") & vbNewLine
message = message & "Predicted Portfolio Gain = " & Format(Range("n4").Value, "percent")
MsgBox message, vbInformation, "Simulated Portfolio Value"
End Sub
Bookmarks