+ Reply to Thread
Results 1 to 10 of 10

Custom Lookup UDF Issue

  1. #1
    Registered User
    Join Date
    11-04-2011
    Location
    Fredericton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Custom Lookup UDF Issue

    I've got an odd issue where a UDF that does a lookup for data into some named ranges goes to #Value when some macros are run in the workbook that do not have anything to do with the UDF lookup. I've included an example file with instructions. If anyone has any idea what is causing this issue it would be greatly appreciated.

    Thanks!

    This issue has also been posted at: http://www.vbaexpress.com/forum/showthread.php?t=39682
    Attached Files Attached Files
    Last edited by tkeating4; 11-04-2011 at 10:46 AM.

  2. #2
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: Custom Lookup UDF Issue

    I tried to recreate as per your steps but the formula still worked fine (not sure if thats because I'm using XL 2003).

    Have you tried protecting cell D5 and B5 when runnning the macro? - macro might be trying to change something that you aren't noticing and will throw an error if its protected...

  3. #3
    Registered User
    Join Date
    11-04-2011
    Location
    Fredericton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Custom Lookup UDF Issue

    I'll see if I can find a computer around here that still has 2003 but our office is all 2007 now... Thanks for taking time to look at it.

  4. #4
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: Custom Lookup UDF Issue

    you might also want to protect all your 'data' sheets and run the macro?

    although from the sounds of it (especially as you say it works fine if the file is saved before running the macro) it might be a bug?

  5. #5
    Registered User
    Join Date
    11-04-2011
    Location
    Fredericton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Custom Lookup UDF Issue

    It certainly seems to acts like a bug to me, but I thought I would see if anyone has some masterful debugging skills that could track down the root cause.

  6. #6
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: Custom Lookup UDF Issue

    in your UDF you have the variable vVal1

    is this variable perhaps used in one of your other macros and is confusing the UDF?

  7. #7
    Registered User
    Join Date
    11-04-2011
    Location
    Fredericton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Custom Lookup UDF Issue

    There is only the one UDF in that test file and no Macros to start. The only macros are the ones that get recorded which would have no variables. I found a computer with Excel 2003 and tested the file and it crapped out the same as in 2007. On the second run through of creating a macro that deletes a random cell the lookup in D5 goes to #Value. (Scratch Head)

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Custom Lookup UDF Issue

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this, then please edit your first post to add links to any and all crossposts in other forums.
    Remember what the dormouse said
    Feed your head

  9. #9
    Registered User
    Join Date
    11-04-2011
    Location
    Fredericton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Custom Lookup UDF Issue

    Found a work around for this issue. It would seem that when the .Find is used within a UDF that is going to be used from a Sheet Cell that random recalculates from Excel will cause it to fail because the ranges the .Find is working on are not ready.

    I was however able to use the Match function to get the same lookup affect and it is stable during these recalculations. If anyone wants to see a sample file let me know and I will do one up and post.

    Thanks.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Custom Lookup UDF Issue

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1