VBA Excel range name test

M

Marie

Is it possible to test in VBA whether a rangename (created in excel) exists?
And therefore run a macro which then deletes only those rangenames which
already exist . Do not wish to dlete all range names just a selection.

This is because the macro creates rangenames to use in the procedure for
copying/formula/prints etc various bits of information and depending how
long the datasheet is the number of ranges may be anything from 1 to 10 but i
wish to start the macro always with none of the "macro created" range names
from its previous execution existing
 
B

Bob Phillips

Why not just delete your selected names, existing or not?

On Error Resume Next
Activeworkbook.Names("name1").Delete
Activeworkbook.Names("name2").Delete
On Error Goto 0
 
M

Marie

Thankyou - This works well

Bob Phillips said:
Why not just delete your selected names, existing or not?

On Error Resume Next
Activeworkbook.Names("name1").Delete
Activeworkbook.Names("name2").Delete
On Error Goto 0

--
__________________________________
HTH

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top