Excel Macro to grab tables from Access database

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi Guys,

I did it but the code is very long, can anyone advises any way to shorten the coding, thus it can run faster?

code as follows:
Sub IMPORTALL2()
'
' IMPORTALL2 Macro
'


'
Dim strFile As String






strFile = ActiveWorkbook.Worksheets("Console").Cells(2, 5).Value
Sheets("A_LTE_LNBTS").Select
Range("A1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNBTS")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL40"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNBTS_BEARER").Select
Range("A1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNBTS_BEARER")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL401"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNCEL").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNCEL")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL402"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNCEL_HC").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNCEL_HC")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL403"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNCEL_PS").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNCEL_PS")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL404"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNCEL_SIB").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNCEL_SIB")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL405"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNCEL_SIBSCHEDULINGLIST").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNCEL_SIBSCHEDULINGLIST")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL406"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNHOIF").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNHOIF")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL407"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNHOW").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNHOW")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL408"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_UFFIM").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_UFFIM")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL409"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_UFFIM_UTRFDDCARFRQL").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_UFFIM_UTRFDDCARFRQL")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4010"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNADJ").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNADJ")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4011"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNADJ_GUGROUPIDLIST").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNADJ_GUGROUPIDLIST")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4012"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_LNADJW").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_LNADJW")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4013"
.Refresh BackgroundQuery:=False
End With
Sheets("A_WCEL_SIB").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_WCEL_SIB")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4014"
.Refresh BackgroundQuery:=False
End With
Sheets("A_WCEL_HC").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_WCEL_HC")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4015"
.Refresh BackgroundQuery:=False
End With
Sheets("A_WCEL").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_WCEL")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4016"
.Refresh BackgroundQuery:=False
End With
Sheets("A_HOPL").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_HOPL")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4017"
.Refresh BackgroundQuery:=False
End With
Sheets("A_ADJL").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_ADJL")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4018"
.Refresh BackgroundQuery:=False
End With
Sheets("A_LTE_IRFIM").Select
Range("B1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$B$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_LTE_IRFIM")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4020"
.Refresh BackgroundQuery:=False
End With
Sheets("A_RNFC").Select
Range("A1").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" + strFile + ";Mode=Share Deny Writ" _
, _
"e;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine" _
, _
" Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New" _
, _
" Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Com" _
, _
"pact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("A_RNFC")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = strFile
.ListObject.DisplayName = "Table_Celcom_LTE_RL4021"
.Refresh BackgroundQuery:=False
End With
Sheets("Console").Select
End Sub


Sub ClearAll2()
'
' ClearAll2 Macro
'


'
Sheets("A_LTE_LNBTS").Select
Cells.Select
Selection.ListObject.QueryTable.Delete
Selection.Clear
Sheets("A_LTE_LNBTS_BEARER").Select
Cells.Select
Selection.ListObject.QueryTable.Delete
Selection.Clear
Sheets("A_LTE_LNCEL").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNCEL_HC").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNCEL_PS").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNCEL_SIB").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNCEL_SIBSCHEDULINGLIST").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNHOIF").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNHOW").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_UFFIM").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_UFFIM_UTRFDDCARFRQL").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_IRFIM").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNADJ").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNADJ_GUGROUPIDLIST").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_LTE_LNADJW").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_WCEL_SIB").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_WCEL_HC").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_WCEL").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_HOPL").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
Sheets("A_ADJL").Select
Columns("B:B").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ListObject.QueryTable.Delete
Selection.ClearContents
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("A_RNFC").Select
Cells.Select
Selection.ListObject.QueryTable.Delete
Selection.Clear
Sheets("Console").Select
End Sub




Hi Guys,

Kindly please guide me if there is any macro to grab lets said 20 tables from access database at specified directory. the access database as per link:

https://www.sendspace.com/file/zhhiq0

thank you
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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