Run time error 1004:A table cannot overlap a range...

dearnemo

New Member
Joined
Apr 13, 2012
Messages
6
<TABLE><TBODY><TR><TD class=votecell></TD><TD class=postcell>I used the macro recorder in Excel 2010 to record the code below. The code is supposed to use a .iqy to pull data from a SharePoint 2010 site. When I run the macro, I receive the following error: A table cannot overlap a range that contains a PivotTable report, query results, protected cells or another table. I have no issue running the .iqy query from excel without using the macro. Any idea what's causing the 1004 error? Thanks in adv!

Code:
Sub Macro1() 
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _ 
    "OLEDB;Provider=Microsoft.Office.List.OLEDB.2.0;", Destination:=Range("$A$1") _ 
    ).QueryTable 
    .CommandType = 5 
    .CommandText = Array( _ 
    "<LIST><VIEWGUID>{50A58D53-347D-4E68-B9BC-CA834F7A068E}</VIEWGUID><LISTNAME>{A486016E-80B2-44C3-8B4A-8394574B9430}</" _ 
    , _ 
    "LISTNAME><LISTWEB>http://pwd-gsops5/_vti_bin</LISTWEB><LISTSUBWEB></LISTSUBWEB><ROOTFOLDER>/Lists/Projects List</RO" _ 
    , "OTFOLDER></LIST>") 
    .RowNumbers = False 
    .FillAdjacentFormulas = False 
    .PreserveFormatting = True 
    .RefreshOnFileOpen = False 
    .BackgroundQuery = False 
    .RefreshStyle = xlInsertDeleteCells 
    .SavePassword = False 
    .SaveData = True 
    .AdjustColumnWidth = True 
    .RefreshPeriod = 0 
    .PreserveColumnInfo = True 
    .SourceConnectionFile = "C:\Users\shress2\Downloads\owssvr.iqy" 
    .ListObject.DisplayName = "Table_owssvr1" 
    .Refresh BackgroundQuery:=False 
End With 
ChDir "C:\Users\shress2\Downloads" 
ActiveWorkbook.SaveAs Filename:="C:\Users\shress2\Downloads\Book1.xlsm", _ 
    FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False 
End Sub


</TD></TR></TBODY></TABLE>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top