bdautrich
New Member
- Joined
- Sep 22, 2022
- Messages
- 19
- Office Version
- 2013
- Platform
- Windows
DomInicB posted
Good morning kenreavy
This little routine will return a msgbox if the named range exists and will do nothing if it doesn't. Any good?
Sub Test()
On Error GoTo Last
If Len(ThisWorkbook.Names("MyRange").Name) <> 0 Then MsgBox "Range Exists"
Last:
End Sub
HTH
As an answer to the question posted a while back.
I thought this answer would apply to my situation. I am trying to check is a defined name exists and then delete it if it does. The spreadsheet has a defined name of Strains. Here is the code below .
If Len(ThisWorkbook.Names("Strains").Name) <> 0 Then Names("Strains").Delete
I get a run time error 1004 Application defined or object defined error. I tried changing ThisWorkbook to ActiveWorkbook but got the same error.
Good morning kenreavy
This little routine will return a msgbox if the named range exists and will do nothing if it doesn't. Any good?
Sub Test()
On Error GoTo Last
If Len(ThisWorkbook.Names("MyRange").Name) <> 0 Then MsgBox "Range Exists"
Last:
End Sub
HTH
As an answer to the question posted a while back.
I thought this answer would apply to my situation. I am trying to check is a defined name exists and then delete it if it does. The spreadsheet has a defined name of Strains. Here is the code below .
If Len(ThisWorkbook.Names("Strains").Name) <> 0 Then Names("Strains").Delete
I get a run time error 1004 Application defined or object defined error. I tried changing ThisWorkbook to ActiveWorkbook but got the same error.