+ Reply to Thread
Results 1 to 6 of 6

Custom Function kicking out mid-function

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Custom Function kicking out mid-function

    I'm trying to develop what is basically a horizontal/vertical lookup. I need to look up the codes associated with individual phone numbers, which are currently organized in a two-dimensional chart. We have different accounting units split up between the different columns, with the different phone numbers on each row beneath the 7-digit code.

    Here's the code I have for this:
    Please Login or Register  to view this content.
    I'm not sure what it is, but if anybody can help, I'm stumped now. Is it possibly because I'm trying to open a .xls intead of an Excel 2010 file?
    Last edited by JasonLeisemann; 01-29-2013 at 04:23 PM. Reason: I caught one error myself, at least. Still not fixed.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Custom Function kicking out mid-function

    Is it possibly because I'm trying to open a .xls intead of an Excel 2010 file?
    It isn't really about the file type, it more that a UDF (a VBA function procedure called from a spreadsheet cell) cannot modify the spreadsheet environment (by opening a file, for example). It looks to me like the function should work just fine if you delete the open command, and have the inventory file already open.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Custom Function kicking out mid-function

    Okay, I've tried that (just commented it out and made sure the file was open), and it's still kicking out at the Set wbTelcom line.

    I tried to comment that out and use the long-form reference to the workbook, and it still boots out at the first line.

    Thanks for the point about the Open though; I didn't know that was a problem, though I thought it might be.

    Current version:
    Please Login or Register  to view this content.
    Last edited by JasonLeisemann; 01-29-2013 at 04:42 PM. Reason: Added revised code.

  4. #4
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Custom Function kicking out mid-function

    Shouldn't the syntax of the Workbook.Open method be:
    Workbooks.Open Filename:="\\files1\TelcomPublicShare\CL Master Long Distance Inventory 2012.xls"?

    You can also ascertain the version of Excel running by code:
    Application.Version Property
    Returns a String value that represents the Microsoft Excel version number.
    If this was helpful then please click the small star icon at the bottom left of my post. A little appreciation goes a long way.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Custom Function kicking out mid-function

    A couple of thoughts:

    When a workbook is open, you usually don't need the entire path to reference the specific workbook, and I'm wondering if this is the error. Try dropping the path identifiers and simply refer to it as "CL Master..."

    I rarely use the structure you are demonstrating here. For my UDF's, any information the UDF needs from the spreadsheet I pass through the argument list. You might try re-writing your UDF to have the wbTelcom information passed to the UDF through the argument list
    Please Login or Register  to view this content.
    called as =getcoding(A1,'[cl master long distance inventory 2012.xls]'!$A$1:$A$30000)

  6. #6
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Custom Function kicking out mid-function

    That was the ticket! I didn't need to have the file path in there, and that's what was ejecting it.

+ 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