Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default How to get a cells' range name

Suppose I make a range consisting of a single cell ...

Is there a way to get the name of the range of that cell from an
ActiveSheet in VBA ?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to get a cells' range name

Maybe...

Option Explicit
Sub testme()

Dim myName As String
myName = ""
On Error Resume Next
myName = ActiveCell.Name.Name
On Error GoTo 0

If myName = "" Then
MsgBox "No name"
Else
MsgBox myName
End If
End Sub



wrote:

Suppose I make a range consisting of a single cell ...

Is there a way to get the name of the range of that cell from an
ActiveSheet in VBA ?

Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get a cells' range name


Hello gimme_this_gimme_that,

The ActiveCell.Name.Name method doesn't work on all versions of
Windows. This method isn't as short but should work with any Windows
version.

Sub GetCellRange()

Dim Rng As Range
For N = 1 To ActiveWorkbook.Names.Count
Set Rng = ActiveWorkbook.Names(N).RefersToRange
If Intersect(ActiveCell, Rng) Is Nothing = False Then
MsgBox "Cell belongs to the Named Range " Rng.Name.Name
Else
MsgBox "Cell doesn't belong to a Named Range"
End If
Next N

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=512028

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to get a cells' range name

What version of windows (and excel) has it failed?

Leith Ross wrote:

Hello gimme_this_gimme_that,

The ActiveCell.Name.Name method doesn't work on all versions of
Windows. This method isn't as short but should work with any Windows
version.

Sub GetCellRange()

Dim Rng As Range
For N = 1 To ActiveWorkbook.Names.Count
Set Rng = ActiveWorkbook.Names(N).RefersToRange
If Intersect(ActiveCell, Rng) Is Nothing = False Then
MsgBox "Cell belongs to the Named Range " Rng.Name.Name
Else
MsgBox "Cell doesn't belong to a Named Range"
End If
Next N

End Sub

Sincerely,
Leith Ross

--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=512028


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get a cells' range name


Hello Dave,

I'm running Excel 2000 on Windows XP.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=512028



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to get a cells' range name

I'm surprised that you've had trouble with this. To a casual observer, I
wouldn't guess that the OS would have anything to do with this.

I never had any trouble with xl2k with WinNT.

Leith Ross wrote:

Hello Dave,

I'm running Excel 2000 on Windows XP.

Sincerely,
Leith Ross

--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=512028


--

Dave Peterson
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
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
how to compute a range of cells based on another range of cells? HAROLD Excel Worksheet Functions 1 December 30th 05 09:32 PM
how to compute a range of cells based on another range of cells? HAROLD Excel Worksheet Functions 2 December 30th 05 07:55 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement Kevin Excel Programming 7 October 5th 04 08:11 PM


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

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

About Us

"It's about Microsoft Excel"