I have a large table that I've defined as "WW60_STRI" in the name manager of excel
I'm trying to write a function that returns the max number in column 1 of the table. Is below the correct syntax to use because I'm getting #value! as result when typing =wlookup(WW60_STRI,"maxdepth") into a cell
Public Function wlookup(Name As String, Retrieve As String)
Set WW60_STRI = Range("WW60_STRI")
Select Case Name
Case WW60_STRI:
Select Case Retrieve
Case "maxdepth"
wlookup = Application.WorksheetFunction.Max(WW60_STRI.Columns(1))
End Select
Case Else
wlookup = "error"
End Select
End Function
Thanks!
CodePudding user response:
WW60_STRI
needs to be enclosed in quotes.
Public Function wlookup(Name As String, Retrieve As String)
Set WW60_STRI = Range("WW60_STRI")
Select Case Name
Case "WW60_STRI":
Select Case Retrieve
Case "maxdepth"
wlookup = Application.WorksheetFunction.Max(WW60_STRI.Columns(1))
End Select
Case Else
wlookup = "error"
End Select
End Function