Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to retreive the name of a named cell in an excel macro

I have no problem in addressing cells with name, adding names to the list but
have not yet found the way to retreive the name of the active cells. If any
one has a clue, this would be very appriciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to retreive the name of a named cell in an excel macro

A named cell is a range object with a string name, so:

Sub Nms()
Range("A1").Name = "NamedCell"
Range("NamedCell").Value = Range("A1").Value
MsgBox Range("NamedCell").Address
End Sub


"Xavier" wrote:

I have no problem in addressing cells with name, adding names to the list but
have not yet found the way to retreive the name of the active cells. If any
one has a clue, this would be very appriciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default How to retreive the name of a named cell in an excel macro

It's awkward because there is no Names collection for the Range object. Also,
a range can have more than one name assigned to it. The following code
displays every name assigned to the active cell only:

Sub AAAAA()
Dim x As Long
For x = 1 To ActiveWorkbook.Names.Count
If Range(ActiveWorkbook.Names(x)).Address = _
ActiveCell.Address Then
MsgBox ActiveWorkbook.Names(x).Name
End If
Next x
End Sub

Hope this helps,

Hutch

"Xavier" wrote:

I have no problem in addressing cells with name, adding names to the list but
have not yet found the way to retreive the name of the active cells. If any
one has a clue, this would be very appriciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to retreive the name of a named cell in an excel macro

Sorry, I missed the key question. Here, look at Nm:

Sub Nms()
Range("A1").Name = "NamedCell"
Range("NamedCell").Value = Range("A1").Value
MsgBox Range("NamedCell").Address
Nm = ActiveCell.Name.Name
MsgBox Nm
End Sub


"Xavier" wrote:

I have no problem in addressing cells with name, adding names to the list but
have not yet found the way to retreive the name of the active cells. If any
one has a clue, this would be very appriciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default How to retreive the name of a named cell in an excel macro

If I name cell E2 "MyCell", the following code returns the name:

Range("E2").Name.name

This only works if it is a single cell named range.

--JP

On Aug 13, 12:35*pm, Xavier wrote:
I have no problem in addressing cells with name, adding names to the list but
have not yet found the way to retreive the name of the active cells. If any
one has a clue, this would be very appriciated.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retreive part of the value from each cell - Macor and/or forumula [email protected] Excel Discussion (Misc queries) 5 October 28th 08 05:32 PM
Macro affecting hyperion retreive Jim May Excel Programming 0 April 5th 06 01:06 PM
VBA Excel Macro to delete contents in named cell reaa Excel Discussion (Misc queries) 1 January 3rd 06 08:16 PM
Macro Using Named Cell Mark Bigelow Excel Programming 0 July 8th 03 07:40 PM
Macro Using Named Cell Dan E[_2_] Excel Programming 0 July 8th 03 07:29 PM


All times are GMT +1. The time now is 07:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"