Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default The Defined Name of An Active Cell

I have quite a few defined range names in an active worksheet. Can I
get the defined NAME of of the range that the activecell resides ( In
VBA of course).

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default The Defined Name of An Active Cell

Adapted from a post by Tom Ogilvy:

Sub nm()
Dim nm As Name, rng As Range
For Each nm In ThisWorkbook.Names
On Error Resume Next
Set rng = nm.RefersToRange
On Error GoTo 0
If Not rng Is Nothing Then
If rng.Parent.Name = ActiveSheet.Name Then
If Not Intersect(rng, ActiveCell) Is Nothing Then
MsgBox "Member of " & nm.Name & ", " & _
rng.Address(external:=True)
' either use "exit for" or continue to loop to see
' if it is in more than one named range
End If
End If
End If
Next

End Sub

Hope this helps
Rowan

"Arishy" wrote:

I have quite a few defined range names in an active worksheet. Can I
get the defined NAME of of the range that the activecell resides ( In
VBA of course).


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default The Defined Name of An Active Cell



Thank you Rowan...and of course Our very dear Tom...
It worked like a charm.

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default The Defined Name of An Active Cell

You're welcome.

"Samir Arishy" wrote:



Thank you Rowan...and of course Our very dear Tom...
It worked like a charm.

*** Sent via Developersdex http://www.developersdex.com ***

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
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
referring to formula in a non active cell from active cell nickname Excel Discussion (Misc queries) 1 June 21st 07 12:11 PM
Application-Defined or Object-Defined Error on simple code Fid[_2_] Excel Programming 1 July 21st 05 08:30 PM
How to count rows in a user-defined AutoFilter or AdvancedFilter is active? Frank Krogh Excel Programming 1 February 26th 04 11:08 AM


All times are GMT +1. The time now is 07:16 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"