+ Reply to Thread
Results 1 to 8 of 8

User defined function returns an error on a standard function used in it.

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    British Columbia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    User defined function returns an error on a standard function used in it.

    I am new to this site and I am looking for help. I have programmed in VB before but not in applications such as Excel.

    I have this code in a VBA module attached to a sheet.

    Please Login or Register  to view this content.
    This is supposed to remove brackets around variable length numeric string data but when run from a cell "=RB(B2)", where B2 contains the string it produces a compiler error pointing to the word "Value" and saying Sub or Function not defined.

    The string would start off like this "[1234567891234]" from a point of sale terminal device database as a reference to a bar code and I need to convert this to a printable bar code. I have another function that generates the printer codes and a font that will print bar codes from the printer codes but I am having trouble with removing the brackets from the database data. I thought I would use another function but this error has cropped up. I know this can be done in other ways but the error is a problematic (annoying).

    What would cause this error?

    Thanks in advance and I hope I have presented it in accordance with the rules.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: User defined function returns an error on a standard function used in it.

    There may be a number of reasons for the error, but I thought this line should be

    Please Login or Register  to view this content.
    Change the number to "Numeric"

    It is also assumed that you have a range of strings on one of your columns

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: User defined function returns an error on a standard function used in it.

    Try this
    Please Login or Register  to view this content.
    ISNUMBER() is an EXCEL function, it only evaluates numbers
    IsNumeric() is VBa, it evaluates both numbers and strings

    Value is not a VBa function, the function Evaluate() is the one to use, however it isn't required in this instance.

    Consider this standard Excel formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    So as a UDF, but why?
    Please Login or Register  to view this content.
    Last edited by Marcol; 01-22-2013 at 04:19 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Registered User
    Join Date
    01-18-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: User defined function returns an error on a standard function used in it.

    Hi,

    Please allow me the following correction to Marcol's formula:
    If IsNumeric(Mid(Code, i, 1)) Then
    RB = RB + Value(Mid(Code, i, 1))
    End If

    With all due respect Marcol...

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: User defined function returns an error on a standard function used in it.

    Hi,

    Please allow me the following correction to Marcol's formula:
    If IsNumeric(Mid(Code, i, 1)) Then
    RB = RB + Value(Mid(Code, i, 1))
    End If

    With all due respect Marcol...

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: User defined function returns an error on a standard function used in it.

    Quote Originally Posted by jbg View Post
    Hi,

    Please allow me the following correction to Marcol's formula:
    ...
    You might have missed my edited post ...

  7. #7
    Registered User
    Join Date
    01-18-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: User defined function returns an error on a standard function used in it.

    Probably... Mea culpa

  8. #8
    Registered User
    Join Date
    01-22-2013
    Location
    British Columbia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: User defined function returns an error on a standard function used in it.

    Thanks to everybody, I have learned that VBA functions and Excel functions are not the same. I have found the VBA reference but I am surprised that I could not get it to show up through help. I have a lot to learn. I will use the formula solution Marcol, thanks. Thanks again for the rapid response.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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