ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining if a named range exists (https://www.excelbanter.com/excel-programming/349581-determining-if-named-range-exists.html)

a

Determining if a named range exists
 
Hello,

Is there a way to determine whether a named range exists in a workbook?
I would think there would be a way. I'm trying to put together an
if statement - but I don't know the syntax. What I'm looking for is "If
the range "first" exists in the workbook, then do this, else . . ."

Any help would be greatly appreciated.

Thanks in advance.

Anita


Bob Phillips[_6_]

Determining if a named range exists
 
Sub RangeNameTes()
Dim rng As Range

On Error Resume Next
Set rng = Range("myRangeNAme")
On Error GoTo 0
If Not rng Is Nothing Then
' it exists
Else
' it doesn't exist
End If

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"a" wrote in message
nk.net...
Hello,

Is there a way to determine whether a named range exists in a workbook?
I would think there would be a way. I'm trying to put together an
if statement - but I don't know the syntax. What I'm looking for is "If
the range "first" exists in the workbook, then do this, else . . ."

Any help would be greatly appreciated.

Thanks in advance.

Anita




a

Determining if a named range exists
 
Bob,

Thanks!

Anita

Bob Phillips wrote:

Sub RangeNameTes()
Dim rng As Range

On Error Resume Next
Set rng = Range("myRangeNAme")
On Error GoTo 0
If Not rng Is Nothing Then
' it exists
Else
' it doesn't exist
End If

End Sub




All times are GMT +1. The time now is 12:09 AM.

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