Hi Grant,
Now I also have another button on the page that is attached to macro. This
macro's purpose is to destroy the data and the range defined by the above
routine. As I explained, the problem is that each time the routine above is
executed it appends an underscore and a number to the name that I have
defined. To complicate matters, this number is incremented after every
execution.
I guess that you have to step through the QueryTables collection of each
sheet:
Dim oQt as QueryTable
Dim oSh as Worksheet
For each oSh in activeworkbook.Worksheets
For Each oQt in oSh.QueryTables
If Left(oQt.Name,8)="NameOfQt" Then
oQt.Delete 'untested
End If
Next
Next
Regards,
Jan Karel Pieterse
Excel MVP
www.jkp-ads.com