Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Get cell name into MsgBox?

I have about 200 cells with names inserted using Insert Name
Define. When I click on a cell, the name shows in the box on the
Formula bar. Often, though, the name is too long for the Name box.

I've been trying to find a way to connect the ActiveCell with the
Workbook Names collection to get the cell name into a message box, but
I haven't found an easy method. It almost looks like I would have to
build a string from the cell's sheet name and row and column
reference, then cycle through the workbook names until I found a name
with a matching RefersTo.

Is it really that complicated? Or is there an easier way?

Ed

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Get cell name into MsgBox?

Here is a little function written by Chip Pearson. Should do the
trick for you.
Function NameOfParentRange(Rng As Range) As String
Dim Nm As Name
For Each Nm In ThisWorkbook.Names
If Rng.Parent.Name = Nm.RefersToRange.Parent.Name Then
If Not Application.Intersect(Rng, Nm.RefersToRange) _
Is Nothing Then
NameOfParentRange = Nm.Name
Exit Function
End If
End If
Next Nm
NameOfParentRange = ""
End Function

Ed from AZ wrote:
I have about 200 cells with names inserted using Insert Name
Define. When I click on a cell, the name shows in the box on the
Formula bar. Often, though, the name is too long for the Name box.

I've been trying to find a way to connect the ActiveCell with the
Workbook Names collection to get the cell name into a message box, but
I haven't found an easy method. It almost looks like I would have to
build a string from the cell's sheet name and row and column
reference, then cycle through the workbook names until I found a name
with a matching RefersTo.

Is it really that complicated? Or is there an easier way?

Ed


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Get cell name into MsgBox?

Actually, give this a shot.
Sub foo()
On Error Resume Next
MsgBox ActiveCell.Name.Name
End Sub

Ed from AZ wrote:
I have about 200 cells with names inserted using Insert Name
Define. When I click on a cell, the name shows in the box on the
Formula bar. Often, though, the name is too long for the Name box.

I've been trying to find a way to connect the ActiveCell with the
Workbook Names collection to get the cell name into a message box, but
I haven't found an easy method. It almost looks like I would have to
build a string from the cell's sheet name and row and column
reference, then cycle through the workbook names until I found a name
with a matching RefersTo.

Is it really that complicated? Or is there an easier way?

Ed


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Get cell name into MsgBox?

Sub GetNameOfCell()
Dim nm As Name
For Each nm In ActiveWorkbook.Names
On Error Resume Next
If nm.RefersToRange.Address(External:=True) = _
ActiveCell.Address(External:=True) Then
If Err.Number = 0 Then
MsgBox nm.Name & vbNewLine & ActiveCell.Address
End If
End If
On Error GoTo 0
Next
End Sub

Or, widen the dropdown beneath the name box:

http://cpearson.com/excel/NameBox.htm

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Ed from AZ" wrote in message
oups.com...
I have about 200 cells with names inserted using Insert Name
Define. When I click on a cell, the name shows in the box on the
Formula bar. Often, though, the name is too long for the Name box.

I've been trying to find a way to connect the ActiveCell with the
Workbook Names collection to get the cell name into a message box, but
I haven't found an easy method. It almost looks like I would have to
build a string from the cell's sheet name and row and column
reference, then cycle through the workbook names until I found a name
with a matching RefersTo.

Is it really that complicated? Or is there an easier way?

Ed



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Get cell name into MsgBox?

If you simply want to see a list of all of the names in a workbook, what
I normally do is insert a new worksheet into the workbook, then use the
Insert|Name|Paste command to list them on the new worksheet.

1. Insert a new worksheet.
2. In cell A1, put "Name".
3. In cell B1, put "Refers to".
4. Format cells A1 and B1 as Bold, with cell underline (or however you
make a list).
5. Select cell A2, then choose the Name|Paste command from the Insert
menu. When the dialog box is displayed, click on the Paste List button.

You can then sort this list anyway you want for ease of use, or print
out the list.

CAUTION: Always use a blank worksheet for this command, since Excel does
NOT ask if it is about to overwrite any data!
--
Regards,
Bill Renaud




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Get cell name into MsgBox?

I chose Chip's dropdown widening code. That works great!

Thanks to all for your assistance.

Ed

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
MsgBox using cell references Jez Excel Programming 3 August 22nd 07 11:08 AM
msgBox after update a cell Claudio Silva Excel Discussion (Misc queries) 10 January 19th 07 10:22 AM
msgbox to display a cell value, HOW, If possible? Corey Excel Programming 2 November 3rd 06 05:23 AM
msgbox if cell is locked scottnshelly[_62_] Excel Programming 1 November 1st 04 08:32 PM
send value to a cell instead on MsgBox morry[_18_] Excel Programming 2 June 10th 04 07:59 PM


All times are GMT +1. The time now is 09:38 AM.

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"