Deleting Define Names

S

Souny

Hello all,

I have define names in my Excel file. Of the define names that I have,
there are particular three define names that I want to delete using the code.
The code that I use is as followed:

for each dName in activeworkbook.names
if dName = "Sheet1!DefineName1" or dName="Sheet1!DefineName2" or
dName="'Sheet 2'!DefineName3" then
dName.delete
end if
next dName

Somehow, the above code is not working and is not deleting those define
names. The above code is a portion of my entire code.

Please help.

Thanks.
 
D

Douglas J. Steele

This newsgroup is for questions about Access, the database product that's
part of Office Professional.

If you're using Access to automate Excel, the line of code

for each dName in activeworkbook.names

is invalid, since Access knows nothing about ActiveWorkbook: you need to
refer to the current instance of Excel for that to be meaningful to Access.

If you're using Excel, you'd be best off reposting to a newsgroup related to
Excel.
 

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