Help with: Function call on left hand side of assignment must return Variant or Object

Mak Dukan 1 Reputation point
2021-11-23T10:13:23.307+00:00

Hi! I know this has been dealt with in other questions but I am unable to identify what is wrong with my code and why do I get the message box "Function call on left-hand side of assignment must return Variant or Object"

Here is the code:

Sub CfD_D90_R001()

Dim iRow As Integer
Dim Pathnumber
Dim CfD

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False

iRow = 0

Sheets("D90").Select
Pathnumber = Range("A2").Value
Range("B5:M6000").Value = ""

Sheets("Profit-Calc").Select
Range("F53").Value = 0.9
Range("F81").Value = "CfD"
Range("F85").Value = "SIM"

Do
iRow = iRow + 1

Range("F86").Value = iRow

Application.Calculate

SH_value1 = Range("F443").Value
SH_return1 = Range("F444").Value
SH_value2 = Range("F449").Value
SH_return2 = Range("F450").Value
FIN_Distress_occured = Range("F436").Value
FIN_Distress_firstyear = Range("F437").Value
NPV = Range("F502").Value
IRR = Range("F503").Value
PVCapital1 = Range("E510").Value
PVCapital2 = Range("E515").Value
DSCR_average = Range("E533").Value
Project_bankable = Range("E537").Value

Sheets("D90").Select
Cells(iRow + 4, 2).Value = SH_value1
Cells(iRow + 4, 3).Value = SH_return11
Cells(iRow + 4, 4).Value = SH_value1
Cells(iRow + 4, 5).Value = SH_return1
Cells(iRow + 4, 6).Value = FIN_Distress_occured
Cells(iRow + 4, 7).Value = FIN_Distress_firstyear
Cells(iRow + 4, 8).Value = NPV
Cells(iRow + 4, 9).Value = IRR
Cells(iRow + 4, 10).Value = PVCapital1
Cells(iRow + 4, 11).Value = PVCapital2
Cells(iRow + 4, 12).Value = DSCR_average
Cells(iRow + 4, 13).Value = Project_bankable
 

Loop Until iRow = Pathnumber

Application.ScreenUpdating = True

End Sub

Thanks for the help!

Mak

{count} votes

1 answer

Sort by: Most helpful
  1. Mak Dukan 1 Reputation point
    2021-11-23T16:11:56.787+00:00

    I solved the issue

    I need to define variables with Dim. I do not have these for all the variables I copy and paste at the end of the code.

    Thanks,

    Mak

    0 comments No comments