+ Reply to Thread
Results 1 to 5 of 5

Write Named Range Name in Cell via VBA

  1. #1
    Registered User
    Join Date
    06-15-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    2

    Write Named Range Name in Cell via VBA

    I have a report I'm building that contains a log sheet whenever a user changes a value on the first page. This page has three named ranges in which users can change or input values. I would like to have the name of the range they edited included in the log sheet message. What I have so far works fine with the exception that it doesn't display the named range name. Is there a way to do this?

    Thanks!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Write Named Range Name in Cell via VBA

    Hi bradleyc and welcome to ExcelForum,

    Thank you for using CODE TAGS around your code.

    See the attached sample file which incorporates the following function into your code:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,635

    Re: Write Named Range Name in Cell via VBA

    Also consider:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 06-25-2015 at 09:32 PM.
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    06-15-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    2

    Re: Write Named Range Name in Cell via VBA

    Thanks for the responses!
    LJ, I tried out your code, and while there is a little extra info (like the sheet names being displayed), it seems to be exactly what I was looking for!

    Leah, I also tried out yours, and I had some questions. When you ReDim the NameInfo array from 1 to Ndx, why do you also have 1 to 2? Ndx should hold 3 (the number of names in my sheet) right? And I was your comment about the name and address being two columns to the right, but where? I looked and didn't see the name anywhere.

    Again, thanks for your responses!

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,635

    Re: Write Named Range Name in Cell via VBA

    I used: ReDim NameInfo(1 To Ndx, 1 To 2)
    1 to Ndx is the number of rows corresponding to the number of names found,
    1 to 2 for a 2 column array;
    range names in column 1 and the range adddress in column 2 (in case it was needed elsewhere).

    .Offset(0, 2).Resize(columnsize:=2).Value = Array(NameInfo(Ndx, 1), NameInfo(Ndx, 2))

    is inside your "With Target" block so it puts the name & address two columns over from the target
    Last edited by protonLeah; 06-26-2015 at 08:13 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Assign named range to one cell depending on named range in another
    By x65140 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2015, 11:04 AM
  2. [SOLVED] determining if cell is part of named range and what that named range is
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2014, 07:56 PM
  3. [SOLVED] Determining if the value of a cell can be a named range, then assigning named ranges after
    By Romulo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2013, 06:05 PM
  4. Replies: 1
    Last Post: 06-03-2006, 10:55 PM
  5. [SOLVED] If any cell in named range = 8 then shade named range
    By JJ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-26-2005, 07:05 PM

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