ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Collection methods (https://www.excelbanter.com/excel-programming/318652-collection-methods.html)

Christopher Benson-Manica

Collection methods
 
How do I delete all the elements in a collection? (Specifically, the
QueryTables collection, but I don't know if that matters).

You'd think this would be trivial, but Excel's VBA help is a horrific
unmitigated disaster.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

Bob Phillips[_6_]

Collection methods
 
N ever used QueryTables, but to clear from a collection you would normally
use

For Each ws in Activeworkbook
For Each qyt In ws.QueryTables
qyt.Delete
Next qty
Next ws

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Christopher Benson-Manica" wrote in message
...
How do I delete all the elements in a collection? (Specifically, the
QueryTables collection, but I don't know if that matters).

You'd think this would be trivial, but Excel's VBA help is a horrific
unmitigated disaster.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.




Tom Ogilvy

Collection methods
 
Dim qt as QueryTable
for each qt in Activesheet.QueryTables
qt.Delete
Next

--
Regards,
Tom Ogilvy

"Christopher Benson-Manica" wrote in message
...
How do I delete all the elements in a collection? (Specifically, the
QueryTables collection, but I don't know if that matters).

You'd think this would be trivial, but Excel's VBA help is a horrific
unmitigated disaster.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.




Christopher Benson-Manica

Collection methods
 
Bob Phillips spoke thus:

For Each ws in Activeworkbook
For Each qyt In ws.QueryTables
qyt.Delete


I see. Now, if Excel's help could have told me that... I know now
that collections have a Count property, but where could I have found
that information, say, on MSDN or the VBA help...?

Next qty
Next ws


--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

Tom Ogilvy

Collection methods
 
Look in the object browser in Excel VBA.

--
Regards,
Tom Ogilvy

"Christopher Benson-Manica" wrote in message
...
Bob Phillips spoke thus:

For Each ws in Activeworkbook
For Each qyt In ws.QueryTables
qyt.Delete


I see. Now, if Excel's help could have told me that... I know now
that collections have a Count property, but where could I have found
that information, say, on MSDN or the VBA help...?

Next qty
Next ws


--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.





All times are GMT +1. The time now is 07:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com