VBA Excel range name test

  • Thread starter Thread starter Marie
  • Start date Start date
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
 
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
 
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
 
Back
Top