So I have a spreadsheet that I import text files to every week for three months. At the end of the three months I have to go in and delete all of the data and the query that I have set up so that I can start over for three more months. I can import them via a macro just fine, but I cannot for the life of me figure out how to get the macro I recorded to delete them to work. I have tried three different macros with no success. The code is below. I would love some help.
The first macro I use creates a yes/no dialog box and calls the macro to delete the actual data and queries.
Sub Macro8()
'
' Macro8 Macro
' Macro recorded 8/15/2008 by Clayton Grove
'
config = vbYesNo
ans = MsgBox("Are you sure you want to remove every Controllables Detail report you have imported?", config)
If ans = vbYes Then Call Macro9
If ans = vbNo Then Exit Sub
End Sub
These are the two macros I have been unsuccessfully trying to get to work.
Sub Macro7()
'
' Macro7 Macro
' Macro recorded 8/15/2008 by Clayton Grove
'
'
Sheets(Array("M1 IE", "M2 IE", "M3 IE", " M1 WK 1", " M1 WK 2", " M1 WK 3", _
" M1 WK 4", " M2 WK 1", " M2 WK 2", " M2 WK 3", " M2 WK 4", "M3 WK 1", "M3 WK 2", _
"M3 WK 3", "M3 WK 4", "M3 WK 5")).Select
Sheets(" M1 WK 1").Activate
ActiveCell.Cells.Select
Selection.ClearContents
Sheets(Array("M1 IE", "M2 IE", "M3 IE", " M1 WK 1", " M1 WK 2", " M1 WK 3", _
" M1 WK 4", " M2 WK 1", " M2 WK 2", " M2 WK 3", " M2 WK 4", "M3 WK 1", "M3 WK 2", _
"M3 WK 3", "M3 WK 4", "M3 WK 5")).QueryTables.Item(11).Delete
End Sub
Sub Macro9()
'
' Macro9 Macro
' Macro recorded 8/15/2008 by Clayton Grove
'
Application.ScreenUpdating = False
ActiveCell.Cells.Select
Selection.ClearContents
Sheets("M2 IE").Select
ActiveCell.Cells.Select
Selection.ClearContents
Sheets("M3 IE").Select
ActiveCell.Cells.Select
Selection.ClearContents
Sheets(" M1 WK 1").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M1 WK 2").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M1 WK 3").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M1 WK 4").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M2 WK 1").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M2 WK 2").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M2 WK 3").Select
ActiveCell.Cells.Select
ActiveCell.Offset(-30, 0).Range("A1").Activate
Selection.ClearContents
Selection.QueryTable.Delete
Sheets(" M2 WK 4").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("M3 WK 1").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("M3 WK 2").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("M3 WK 3").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("M3 WK 4").Select
ActiveCell.Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets(" Month 1 Totals").Select
End Sub
Here is a link to the workbook, if that will help.
http://www.4shared.com/file/59168046...V3AWESOME.html
Thanks for any help you can give me, because I am at a complete loss right now.
Clayton Grove
Bookmarks