我有一个简单的VBA功能,该功能保存在受信任的启用宏的工作簿的ThisWorkbook中。此功能的代码:GetParameterKey
在下面。
我想从同一工作簿中的工作表中调用GetParameterKey
作为电子表格函数。但是,GetParameterKey
不会在“插入功能”下显示为用户定义的功能。
是否可以从同一工作簿的工作表中调用ThisWorkbook部分中定义的函数?
Public Function GetParameterKey(natureOfWork As String, size As String, complexity As String, uncertainty As String) As String
'
' GetParameterKey Macro
' Computes a VLOOKUP key for Nature of Work, Size, Complexity, and Uncertainty.
'
Select Case UCase(Trim(natureOfWork))
Case "BACK END"
GetParameterKey = "1"
Case "FRONT END"
GetParameterKey = "2"
Case "BOTH"
GetParameterKey = "3"
Case Else
GetParameterKey = "0"
End Select
GetParameterKey = GetParameterKey & CategoryKey(size)
GetParameterKey = GetParameterKey & CategoryKey(complexity)
GetParameterKey = GetParameterKey & CategoryKey(uncertainty)
End Function
Function CategoryKey(category As String) As String
Select Case UCase(Trim(category))
Case "VERY LARGE"
CategoryKey = "5"
Case "LARGE"
CategoryKey = "4"
Case "MEDIUM"
CategoryKey = "3"
Case "SMALL"
CategoryKey = "2"
Case Else
CategoryKey = "1"
End Select
End Function