Hi all, trying to have a query delete on workbook close. What is happining is I have a cmd button for retriving a Quiry,but If I re-open the workbook and click the button again, I have double data, so I thought I could just delete the query on the page befroe closing. This is what I have,it hangs on this line
(Selection.QueryTable.Delete)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Range("B2:I1118").Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("Sheet2").Select
Range("D8").Select
End Sub
(Selection.QueryTable.Delete)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Range("B2:I1118").Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("Sheet2").Select
Range("D8").Select
End Sub