Consulting

Results 1 to 5 of 5

Thread: Solved: display range's "refer to"

  1. #1
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location

    Solved: display range's "refer to"

    Is there a simple way to display a range's areas or formulas, as you see under menu item Insert/Name/Define ? I.e., the "refers to" string?

    If not, would I need to parse and loop with regions and areas? Would I
    - check .HasFormula and then grab .Formula? or .FormulaR1C1?
    - take rng.areas.count and build it with semicolons if multiple?
    - loop through that count with the "Items?" How do I address them? rng(1), rng(2) ?!
    Use .Formula or .Text ?

    Tell me it's already available, please!
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You can use Address to get that.

    [VBA]
    Range("A1").Address
    Range("MyRange").Address
    [/VBA]

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Or if you wanted to see the formula and the resulting address:

    [VBA]
    Option Explicit

    Sub NamesTest()

    Dim N As Name

    For Each N In ThisWorkbook.Names
    MsgBox N.RefersTo
    MsgBox Range(N.Name).Address
    Next N

    End Sub
    [/VBA]

  4. #4
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    Quote Originally Posted by DRJ
    MsgBox N.RefersTo
    MsgBox Range(N.Name).Address
    Outstanding
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  5. #5
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hi there,

    If you're just looking to show the formula in a cell, I have an article to do that here.

    HTH,
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

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