Consulting

Results 1 to 3 of 3

Thread: Unable to locate named range in code

  1. #1

    Unable to locate named range in code

    I am new to Excel VBA. I have been given a large Excel file with several macros and I am tracing the code flow. My understanding of this code:

    Worksheets("ABC").Activate
    Range("abc_name").Select
    is that the sheet ABC should get the focus and that some range on this sheet must already have been already named "abc_name" somewhere in the code. However, I cannot find the string "abc_name" anywhere in any of the modules that affect this workbook.

    Advice is appreciated.

  2. #2
    The range was named in the Excel file itself. I was mistakenly under the impression that the code was responsible for creating this workbook but it simply receives it, as is, and operates on it.

  3. #3
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Dim Nme As object
    For each Nme in ThisWorkbook.Names
    MsgBox Nme.Name & " Refers to " & Nme.
    Next
    
    ThisWorkbook.Names.Add Name:="MyRangeName", RefersTo:="=Sheet1!A1:A3"
    
    For each Nme in ThisWorkbook.Names
    If Nme.RefersTo = "=Sheet1!A1:A3" Then MsgBox Nme.Name
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •