Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Named Ranges in Excel

Status
Not open for further replies.

robolo7

Programmer
Jun 19, 2002
1
GB
How can I get access to each of the named ranges I've created in an Excel Worksheet so that I can delete them?

I can't use For Each construct to loop through the Names collection as I'm not using VB here (actually Delphi).

I'm using for I = 1 to Names.Count
Range = Workbook.Names(I)

This doesn't work - does anyone have an idea?

Thanks

David
 
David,

Try

Code:
For I = 1 to Names.Count
  Names(I).Delete
Next I


HTH
Mike
 
Are you trying to delete the names, or the ranges they reference? If the former, Mike's approach should work. If the latter, try

for each oName in Names
range(oName.name).clear
next oName
Rob
[flowerface]
 
Rob,

Just a follow-up. David is using Borland's Delphi programming environment so he doesn't have the For..Each construct available. He would need to use something like:

Code:
For I:=1 To Names.Count
  Range(Names(I)).Clear;

although I'm not sure how he is referencing Excel objects in Delphi (my experience with Delphi programming is limited).


Regards,
Mike
 
Oops - overlooked that little snippet of info at the top. Ah, if only I could be programming in a Pascal-like language again...
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top