ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   check if name object exists (https://www.excelbanter.com/excel-programming/381453-check-if-name-object-exists.html)

mark kubicki

check if name object exists
 
is there a function to see if a name object exists?


(thanks in advance)



Chip Pearson

check if name object exists
 
Try a function like


Function NameExists(WhatName As String) As Boolean
Dim S As String
On Error Resume Next
S = ThisWorkbook.Names(WhatName).Name
NameExists = (Err.Number = 0)
End Function

You call this with code like

If NameExists(WhatName:="MyRangeName") = True Then
' whatever
Else
' something
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"mark kubicki" wrote in message
...
is there a function to see if a name object exists?


(thanks in advance)





All times are GMT +1. The time now is 12:23 PM.

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