+ Reply to Thread
Results 1 to 3 of 3

Painfully simple... help?

  1. #1
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Unhappy Painfully simple... help?

    I am just getting started with VBA and working through John Green's Excel 2000 VBA Programmer's Reference text. I'm having trouble getting the last example in the Primer Chapter to work and it's driving me crazy.

    If anyone could look at the code and tell me why they think it isn't working I'd greatly appreciate it.

    Thanks

    Here is the code the book has for the example and what I'm using.

    >
    Sub TestForName()
    If NameExists("SalesData") Then
    MsgBox "Name Exists"
    Else
    MsgBox "Name does not exist"
    End If
    End Sub

    Function NameExists(myName As String) As Boolean
    Dim x As String
    On Error Resume Next
    x = Names(myName).RefersTo
    If Err.Number <> 0 Then
    NameExists = False
    Err.Clear
    Else
    NameExists = True
    End If
    End Function
    >

    No matter what I have in the worksheet I get the False result in the message box stating that the Name Does Not Exist.

    HELP!

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    go to insert->name->define, type in SalesData and click ok.

    Now execute the macro

  3. #3
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Thank You,
    I thought I was searching the sheet contents for the Name not a set of predefined name ranges.

+ 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