View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Brandt Brandt is offline
external usenet poster
 
Posts: 33
Default UDF Looks for Named Range Not Function

Strange Problem Here...

I had a cell that created a job number using some very long formulas to
check the folder path where the spreadsheet was stored and parse out a job
number. I had named the cell "JobNum". In other cells where I wanted the
job number to show I would enter "=JobNum". This worked fine but the cell
method was very cumbersome and so I changed it to use a UDF in VBA. The user
defined function is "Public Function JobNum()". For the cell to call the
function, I first have to delete the named range "JobNum" via
Insert|Name|Define menu, then I change the formula in the cell from "=JobNum"
to "=JobNum()". This has worked fine for many spreadsheets that I have
updated to use the VBA method instead of the cell method. However, today I
opened up a spreadsheet that I had not yet updated, deleted the name
(JobNum), imported the module that has the "JobNum" function (like I have
done many times) and changed the fromula to "=JobNum()". This time however I
get a €œ#Name?€ error in the cell that calls the "JobNum()" function. I have
triple checked that I have deleted the cell name correctly. There are no
other worksheets in the file (at least that I can see from the tabs or from
VBA project window). Furthermore, when I "evaluate" formula on a "=Today()"
function that is in the spreadsheet, it initially shows the entire function
underlined including the "()" before it evaluates it. However, when I
evaluate the "=JobNum()" function only the "JobNum" part is underlined (and
not the parenthesis) which leads me to believe that the spreadsheet still
thinks "JobNum" is a named range. I have put a stop in my VBA code and
verified that the UDF is never even called. (If I change both the cell
formula and function name to €œJobNum1()€ it works fine, however I am
interested in solving this problem and also in keeping this method consistent
with the many other spreadsheets that use this UDF.)

I've tried everything I can think of. Does anyone have any ideas?

Thanks in Advance