+ Reply to Thread
Results 1 to 6 of 6

Referring to a defined name in VBA

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Referring to a defined name in VBA

    I have a subroutine in which I want to check to see if a variable ("NameA") is within a defined name ("ListA") within my workbook. "NameA" is defined within the VBA as a string. I get an error on the If statement stating "Method range of object Global failed"
    Please Login or Register  to view this content.
    So if the variable NameA can be found in ListA, then IsNumber will be True

    How do I fix this?

    Thanks

    ChemistB

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You can use Match, but this is what I'm accustomed to:
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    The syntax for using an Excel application function in the VBE is:

    Application.WorksheetFunction.Match(..........etc...), rather than just Application.Match(.....)

    try including the missing 'WorksheetFunction' bit and see if that helps.

    Rgds

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Could also look at the iif function and look at replacing
    Please Login or Register  to view this content.
    for
    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Quote Originally Posted by Richard
    Application.WorksheetFunction.Match(..........etc...), rather than just Application.Match(.....)
    That part will work either way, but using WorksheetFunction will allow Intellisense to work.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Thanks to all of you. I will play with the coding today.

    ChemistB

+ 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