0

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!

0

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

thanks. looks like I should be using quotes in the cell also: =wlookup("WW60_STRI","maxdepth")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.