Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
When entering data into a range of cells, select the entire range. | Excel Discussion (Misc queries) | |||
how to compute a range of cells based on another range of cells? | Excel Worksheet Functions | |||
how to compute a range of cells based on another range of cells? | Excel Worksheet Functions | |||
Compare a selected Range with a Named range and select cells that do not exist | Excel Programming | |||
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement | Excel Programming |