ClearContents Not Clearing Query

  • Thread starter Thread starter Sean McPoland
  • Start date Start date
S

Sean McPoland

Hi ya'll

I have a sheet with a Import External Data from Access
query on it.

I am trying to programatically clear it with the
following code:

Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Range("A1").Select

When I do it manually it works and the query is removed
from the sheet, but in the VBA module it does not remove
the query.

Am I doing something wrong or can someone help me with
this problem?

Thanks in advance
regards
Sean
 
try
Sub noquery()
With ActiveSheet
..UsedRange.ClearContents
..QueryTables(1).Delete
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top