LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to return rangename of selection with VBA


I'm looking for the most efficient way to return the first rangename
which includes the current selection. And the current selection can be
a single cell.

At the moment, I'm using this routine:
-Function GetRangename(ByVal SelRng As Range) As String
On Error Resume Next
Dim nme As name
For Each nme In ThisWorkbook.Names
If Union(Range(nme), SelRng) = Range(nme) Then
GetRangename = nme
Exit Function
End If
Next nme
End Function-

As far as I know, there's no direct VBA object that returns the first
rangename which includes the cell you selected. And if I have to return
multiple rangenames, the routine needs to go through all existing
rangenames again...

Anyone got any more efficient way?

Regards,
shoba


--
shoba
------------------------------------------------------------------------
shoba's Profile: http://www.excelforum.com/member.php...o&userid=24676
View this thread: http://www.excelforum.com/showthread...hreadid=382505

 
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
Testing For a RangeName JCS Excel Discussion (Misc queries) 3 August 13th 08 01:08 PM
Confused with RangeName CellREfs Jim May Excel Discussion (Misc queries) 1 October 22nd 06 11:11 PM
ActiveWorkbook.Protect password:=range("rangename") does not work WimR Excel Discussion (Misc queries) 1 June 26th 05 08:47 AM
VBA - Syntax filename rangename for vlookup formula Thomas[_18_] Excel Programming 4 December 3rd 04 01:42 AM
Concatenate RangeName for INDEX? CLR Excel Worksheet Functions 5 November 30th 04 07:47 PM


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