ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Name Found?? (https://www.excelbanter.com/excel-programming/286976-range-name-found.html)

Michael Kintner

Range Name Found??
 
If I wanted to check to see if a range name exists would I do?



--
Thank you for your help in advance!!! (smile)

Mike



Charles Maxson

Range Name Found??
 
Micheal,

Here is a function (with a test sub) that will return t/or/f if your name
exists:

Sub Test()
MsgBox RangeNameExists("test")
End Sub

Function RangeNameExists(sRangeName As String) As Boolean
Dim rng As Range
On Error Resume Next

Set rng = Range(sRangeName)

If Not rng Is Nothing Then
RangeNameExists = True
End If

End Function


--
Charles
www.officezealot.com


"Michael Kintner" wrote in message
...
If I wanted to check to see if a range name exists would I do?



--
Thank you for your help in advance!!! (smile)

Mike





Jake Marx[_3_]

Range Name Found??
 
Hi Michael,

Here's another alternative (shorter, but accomplishes the same thing as
Charles's):

Public Function gbValidRange(rsName As String) As Boolean
On Error Resume Next
gbValidRange = Len(Range(rsName).Name)
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Michael Kintner wrote:
If I wanted to check to see if a range name exists would I do?




All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com