Thread: if statement
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default if statement

Public Function NameExists(val As String)
Dim nme
On Error Resume Next
nme = ActiveWorkbook.Names(val)
On Error GoTo 0
NameExists = (Not IsEmpty(nme))
End Function


If NameExists("xyz" Then
...

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"BorisS" wrote in message
...
Need an if statement to check if a certain named data range (call it
"testrange") exists or not? I am going to create it if it is not there,
and
if it is, I need to delete it. So have to check, otherwise will get run
error.

Thx.
--
Boris