Wednesday, November 28, 2007

Removing External Data References from Excel

I really enjoy working with both Excel and Access when trying to solve quick data collection issues.

However, sometimes after you caputre the data inside of the Excel Spreadsheet from Microsoft Access you want to freeze the data in Excel.

Here is the fastest way to drop all the data links to external resources from inside of Microsoft Excel to create a snap shot in time.

Sub Delete_All_Queries()

Dim myQueryTables As QueryTable

Dim myWorkSheets As Worksheet

For Each myWorkSheets In ThisWorkbook.Worksheets

For Each myQueryTables In myWorkSheets.QueryTables
myQueryTables.Delete
Next myQueryTables
Next myWorkSheets

End Sub

1 comment:

Unknown said...

I run the macro, but still when i want to save the workbook as Excel Macro-Enable Template, is saying that i have external data,
so how i can i get rid of that