mikeoly
12-08-2012, 09:52 PM
Could anyone help me convert this into VBA code?
=NPV($C$41,$D$71:$H$71)+H94/((1+$C$41)^5)
~~~~~~~~~~~~~~~~~~
Also, does anyone know why I get a 'application defined or object defined error' in the 4th line from the bottom?
Private Sub cbOK_Click()
Dim Scenario As Single
Scenario = Right(ListBox1.Value, Len(Scenario) - (Len(Scenario) - 1))
For r = 1 To ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Rows.Count
For c = 1 To ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Columns.Count
ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Cells(r, c).Value = ActiveWorkbook.Worksheets("Sheet3").Range("R1.&Scenario&").Cells(r, c).Value
Next c
Next r
End Sub
=NPV($C$41,$D$71:$H$71)+H94/((1+$C$41)^5)
~~~~~~~~~~~~~~~~~~
Also, does anyone know why I get a 'application defined or object defined error' in the 4th line from the bottom?
Private Sub cbOK_Click()
Dim Scenario As Single
Scenario = Right(ListBox1.Value, Len(Scenario) - (Len(Scenario) - 1))
For r = 1 To ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Rows.Count
For c = 1 To ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Columns.Count
ActiveWorkbook.Worksheets("Sheet1").Range("RiskCompile").Cells(r, c).Value = ActiveWorkbook.Worksheets("Sheet3").Range("R1.&Scenario&").Cells(r, c).Value
Next c
Next r
End Sub