View Single Post
  #1  
Old 03-08-2006, 03:34 PM
slimswol slimswol is offline
Registered User
 
Join Date: 28 Feb 2006
Posts: 10
slimswol is becoming part of the community
Angry call multiple macros in workbook_open?

Hi,
I almost have a program running for excel. I am trying to call multiple macros from "ThisWorkbook". The code below is supposed to delete the current QueryTable and then after the QueryTable is deleted I call a macro to add the new data. It currently does work for one sheet/QueryTable/Macro. But I am not sure how to do this for multiple sheets/QueryTables/Macros ?

My question is how do I delete querytables and call multiple macros from the "Workbook_Open" function?

If it is not possible, is there another way to do this?



Private Sub Workbook_Open()


With Worksheets("Sheet1_RawData")

.QueryTables(1).ResultRange.ClearContents

End With


With Worksheets("Sheet1_RawData")

.QueryTables(1).Delete

End With


Dim qt As QueryTable

For Each qt In Sheets("Sheet1_RawData").QueryTables
'Clear QT data
qt.ResultRange.ClearContents

'Delete QT named range from workbook

Sheets("Sheet1_RawData").qt(1).Delete

'Delete query table
qt.Delete
Next qt

'Call macro to run new query
Call URL_Sheet1_Query

End Sub
Reply With Quote