In order for me to create a filter list on my worksheet, I'm having to first delete
a querry report that's being stored/generated from the data being imported into my
workbook.
Due to Run-Time Error'1004
A list cannot overlap a range that contains a pivotTable report,query results,protected cells or another list.
Initially, I only had 1 ActiveSheet.QueryTable to delete ("IN Stock Status Report - 6896_12"), but this also changed when I ran on another PC under someone else's account.
I'm hoping that maybe I can use a wildcard "in the sense" to delete all occurrences that
may appear.
The following are macros recorded to log what's needing to be deleted.
Sub Macro5()
'
' Macro5 Macro
' Macro recorded 2/12/2010 by BDB
'
'
Range("A6:E19").Select
ActiveSheet.QueryTables("IN Stock Status Report - 6896_22").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_21").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_20").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_19").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_18").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_17").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_16").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_15").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_14").Delete
ActiveSheet.QueryTables("IN Stock Status Report - 6896_13").Delete
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$6:$E$19"), , xlYes).Name = _
"List1"
Range("E23").Select
End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2/11/2010 by BDB
'
'
Range("A6:C16").Select
' If ActiveSheet.QueryTable.Name = ("IN Stock Status Report - 6896.IRP") Then
ActiveSheet.QueryTables("IN Stock Status Report - 6896.IRP").Delete
' Else
' ActiveSheet.QueryTables("IN Stock Status Report - 6896_12").Delete
' End If
' ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$6:$E$16"), , xlYes).Name = _
' "List1"
' Range("A6:C17").Select
End Sub
I'm hoping for something like this:
ActiveSheet.QueryTables("IN Stock Status Report - 6896_*").Delete
..but that does not work.
Here's a bit of code that brings in the querry report.
Next MyRow
Sfile = MostRecent(sPath, "IN Stock Status Report - *.IRP")
If Len(Sfile) = 0 Then
MsgBox "Not found"
Exit Sub
End If
'MyRange = Cells(MyRow, 1).Offset(0, 1)
With Sheets("MASTER").QueryTables.Add _
(Connection:="TEXT;" & Sfile, Destination:=Range("A1").Offset(0, 1))
' Destination: = Cells(1, 1).Offset(0, 1)
.Name = Replace(Sfile, sPath, "")
.Name = "IN Stock Status Report - 6896.IRP"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(11, 49, 9, 8, 10, 8, 8, 7, 6, 6, 6)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Any help is appreciated.
Thanks,
BDB
Bookmarks