Excel 编译错误:函数调用位于赋值的左侧

Excel 编译错误:函数调用位于赋值的左侧,excel,vba,Excel,Vba,我得到了编译错误 “赋值左侧的函数调用必须返回变量或对象” 尝试修复继承的Excel文件,该文件计算与HVAC相关的各种值。该文件依赖于一对包含许多功能的加载项.xLA文件。我无法从大多数函数中获得结果。要么我得到的数字立即变为零,要么我得到的只是#值和#名称错误 我的VBA技能以及我对该文件正在执行的计算的知识有些有限 Function EvapDeltaGrn(altitude, evap_on, tdb_ma, hr_ma, sat_goal, hr_min) 'use to ca

我得到了编译错误

“赋值左侧的函数调用必须返回变量或对象”

尝试修复继承的Excel文件,该文件计算与HVAC相关的各种值。该文件依赖于一对包含许多功能的加载项.xLA文件。我无法从大多数函数中获得结果。要么我得到的数字立即变为零,要么我得到的只是#值和#名称错误

我的VBA技能以及我对该文件正在执行的计算的知识有些有限

Function EvapDeltaGrn(altitude, evap_on, tdb_ma, hr_ma, sat_goal, hr_min)
    'use to calculate the delta grain when tdb_oa > than sat_goal

    EvapDeltaGrn = 0

    If tdb_ma = "" Then Exit Function
    If hr_ma = "" Then Exit Function

    If evap_on Then
        If tdb_ma >= (sat_goal) Then 'use evaporative cooling
            Enthalpy = Application.Run("'psychrometric functions.xla'!TdbGrainstoEnthalpy", altitude, tdb_ma, hr_ma)
            'Range("v14") = enthalpy
            EvapDeltaGrn = Application.Run("'psychrometric functions.xla'!TdbEnthalpytoGrains", altitude, sat_goal, Enthalpy)
            EvapDeltaGrn = EvapDeltaGrn - hr_ma
            EvapDeltaGrn = Round(EvapDeltaGrn, 2)
        Else    'evaporative humidification
            If hr_ma < hr_min Then EvapDeltaGrn = Round(hr_min - hr_ma, 2)
        End If
    End If
End Function
功能EvapDeltaGrn(高度、蒸发打开、tdb\u ma、hr\u ma、sat\u目标、hr\u min)
'用于计算tdb_oa>超过sat_目标时的增量粒度
EvapDeltaGrn=0
如果tdb_ma=“”,则退出函数
如果hr_ma=“”,则退出函数
如果evap_打开,则
如果tdb_ma>=(sat_目标),则“使用蒸发冷却
焓=Application.Run(“'hythrometric functions.xla'!TDBGrainsto焓”),海拔高度,tdb_ma,hr_ma)
'范围(“v14”)=焓
EvapDeltaGrn=Application.Run(“'psychrometric functions.xla'!TdbEnthalpytoGrains”,海拔高度,sat\U目标,焓)
EvapDeltaGrn=EvapDeltaGrn-hr\u ma
EvapDeltaGrn=圆形(EvapDeltaGrn,2)
埃尔斯蒸发增湿
如果hr_ma

错误似乎出现在
焓=

是否有另一个名为
焓的函数?今天我学习了如何使用
应用程序返回值。运行
@sadele89谢谢!始终声明变量,并始终在代码顶部添加
Option Explicit
,以防止您不这样做。
'psychrometric functions.xla'的数据类型是什么!TDBGRAINSTO焓
返回?焓应是什么数据类型?所有其他变量也是如此。您是否有另一个名为
的函数?今天我学习了如何使用
应用程序返回值。运行
@sadele89谢谢!始终声明变量,并始终在代码顶部添加
Option Explicit
,以防止您不这样做。
'psychrometric functions.xla'的数据类型是什么!TDBGRAINSTO焓
返回?焓应是什么数据类型?所有其他变量也是如此。