Hi,
I'm trying to figure out what is wrong with this recorded macro.
Why is ListObject.DisplayName = "Table_Query_from_Excel_Files" showing up as an error?
' Macro9 Macro
'
'
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=Excel Files;DBQ=P:\00 Sales Administration\GPR Check\15-04 April GPR data v2.xls;DefaultDir=P:\00 Sales Administration\GPR " _
), Array("Check;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;")), Destination _
:=Range("$A$2")).QueryTable
.CommandText = Array( _
"SELECT `data$`.`Responsible person`, `data$`.Category, `data$`.SALES_TYPE, `data$`.CUST_CODE, `data$`.CUST_PN, `data$`.DENSO_PN, `data$`.PROD_CODE, `data$`.FIS, `data$`.FIS_CURR, `data$`.VENDOR, `data" _
, _
"$`.FOB, `data$`.`FOB currency`, `data$`.`Actual GPR`, `data$`.`Exp# FOB`, `data$`.`Exp# GPR`, `data$`.QTY, `data$`.`Value of error`" & Chr(13) & "" & Chr(10) & "FROM `P:\00 Sales Administration\GPR Check\15-04 April GPR data v2." _
, _
"xls`.`data$` `data$`" & Chr(13) & "" & Chr(10) & "WHERE (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='Loss') OR (`data$`.`Responsible person`='Fawwaz Siddiqi') AND (`data$`.Category='Loss') OR (`data$`." _
, _
"`Responsible person`='Serkan Kucuk') AND (`data$`.Category='Loss') OR (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Fawwaz Sidd" _
, _
"iqi') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Serkan Kucuk') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Colin Norton') AND (`data$`.Category='L" _
, _
"oss') OR (`data$`.`Responsible person`='Colin Norton') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='High Profit') OR (`data$`.`Respons" _
, _
"ible person`='Fawwaz Siddiqi') AND (`data$`.Category='High Profit') OR (`data$`.`Responsible person`='Serkan Kucuk') AND (`data$`.Category='High Profit') OR (`data$`.`Responsible person`='Colin Norton" _
, "') AND (`data$`.Category='High Profit')")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_Excel_Files" .Refresh BackgroundQuery:=False
End With
Range("D5").Select
ActiveWindow.SmallScroll Down:=138
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
ActiveWindow.SmallScroll Down:=-180
End Sub
Hope you can help
I'm trying to figure out what is wrong with this recorded macro.
Why is ListObject.DisplayName = "Table_Query_from_Excel_Files" showing up as an error?
' Macro9 Macro
'
'
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=Excel Files;DBQ=P:\00 Sales Administration\GPR Check\15-04 April GPR data v2.xls;DefaultDir=P:\00 Sales Administration\GPR " _
), Array("Check;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;")), Destination _
:=Range("$A$2")).QueryTable
.CommandText = Array( _
"SELECT `data$`.`Responsible person`, `data$`.Category, `data$`.SALES_TYPE, `data$`.CUST_CODE, `data$`.CUST_PN, `data$`.DENSO_PN, `data$`.PROD_CODE, `data$`.FIS, `data$`.FIS_CURR, `data$`.VENDOR, `data" _
, _
"$`.FOB, `data$`.`FOB currency`, `data$`.`Actual GPR`, `data$`.`Exp# FOB`, `data$`.`Exp# GPR`, `data$`.QTY, `data$`.`Value of error`" & Chr(13) & "" & Chr(10) & "FROM `P:\00 Sales Administration\GPR Check\15-04 April GPR data v2." _
, _
"xls`.`data$` `data$`" & Chr(13) & "" & Chr(10) & "WHERE (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='Loss') OR (`data$`.`Responsible person`='Fawwaz Siddiqi') AND (`data$`.Category='Loss') OR (`data$`." _
, _
"`Responsible person`='Serkan Kucuk') AND (`data$`.Category='Loss') OR (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Fawwaz Sidd" _
, _
"iqi') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Serkan Kucuk') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Colin Norton') AND (`data$`.Category='L" _
, _
"oss') OR (`data$`.`Responsible person`='Colin Norton') AND (`data$`.Category='Low Profit') OR (`data$`.`Responsible person`='Daniel Robinson') AND (`data$`.Category='High Profit') OR (`data$`.`Respons" _
, _
"ible person`='Fawwaz Siddiqi') AND (`data$`.Category='High Profit') OR (`data$`.`Responsible person`='Serkan Kucuk') AND (`data$`.Category='High Profit') OR (`data$`.`Responsible person`='Colin Norton" _
, "') AND (`data$`.Category='High Profit')")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_Excel_Files" .Refresh BackgroundQuery:=False
End With
Range("D5").Select
ActiveWindow.SmallScroll Down:=138
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
ActiveWindow.SmallScroll Down:=-180
End Sub
Hope you can help