UDF returning #Value when another file is opened

Ray Bailey

New Member
Joined
Nov 12, 2015
Messages
34
Hi,

I've cut this down as much as I can but the full file has 28 columns and 2000+ rows.

I'm trying to insert functions into a worksheet so that the users can find data based the value in column A. Effectively doing a vlookup via a function. Reason for this is that user are not too handy with vlookups etc, each user will want data in different columns depending on their own requirements & I don't want them to have direct access to the master file.

Tab SLA_Calc simply has "12345" in A1 and "Active" in B1

Tab Tracker has "12345" in A1 and "=zStatus(A1)" in B1 ... zStatus is the function below and returns "Active"

The function works find (in sample and full file) until I open another workbook and the zStatus function return #Value

Where am I going wrong???

Code:
Function zStatus(iRec)


    Application.Volatile


    Dim rng As Range
    Dim col As Integer
    Dim found As Variant


    Set rng = Sheets("SLA_Calc").Columns("A:B")


    On Error Resume Next
    found = Application.VLookup(iRec, rng, 2, 0)
    If IsError(found) Then
        zStatus = "Not Found"
    Else
        zStatus = found
    End If
    On Error GoTo 0


End Function
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Does the other workbook contain a sheet named "SLA_Calc"?
 
Upvote 0
Hi Joe,

No, there's no duplication with sheet or function names.

I've just done File > New then saved as Book1, so nothing entered. Closed and re-opened, Still get the same issue.


Cheers

Ray
 
Upvote 0

Forum statistics

Threads
1,214,853
Messages
6,121,935
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top