+ Reply to Thread
Results 1 to 5 of 5

Using a Defined Name in VBA

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

    Using a Defined Name in VBA

    I have a single cell in Worksheet "instructor" defined as "WrongAnswer" with Workbook Scope. I am using this code assigned to a User form
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Works fine until I add WrongAnswer. Do I need to define the variable in VBA (if so, what as, Long?) or include the worksheet name ie. sheets("instructor").range("WrongAnswer").Value

    I tried several options but it's not picking up the defined name. Thanks
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Using a Defined Name in VBA

    Try this:-
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Using a Defined Name in VBA

    Try either Sheets("Instructor").Range("WrongAnswer").Value, Range("WrongAnswer").Value or [WrongAnswer].
    If posting code please use code tags, see here.

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

    Re: Using a Defined Name in VBA

    Perfect Mick. Thanks!

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Using a Defined Name in VBA

    Your welcome
    Regrds Mick

+ 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