Cleanup MS Query Macro Recorded Code

bs0d

Well-known Member
Joined
Dec 29, 2006
Messages
622
I'm curious what items are necessary in the Macro Recorded MS Query code. Below is an example. What items can you remove, and will it improve the speed of the query at all?

For example, can you alter the buffer size up or down? What are the implications? PageTimeout? And all the "FALSE" items below, what if you didn't list those properties at all?

Code:
With 
Sheets("GroupData").ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=L:\Historical\db\history.accdb;DefaultDir=L:\Production - Historical\db;DriverId=2" _
        ), Array("5;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:= _
        Sheets("GroupData").Range("$A$1")).QueryTable
.CommandText = sSQL
.RowNumbers = False
 .FillAdjacentFormulas = False
 .PreserveFormatting = False
 .RefreshOnFileOpen = False
 .BackgroundQuery = True
 .RefreshStyle = xlOverwriteCells
 .SavePassword = False
 .SaveData = True
 .AdjustColumnWidth = False
 .RefreshPeriod = 0
 .PreserveColumnInfo = True
 .ListObject.DisplayName = "QueryGroupData"
 .Refresh BackgroundQuery:=False
End With
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Does anyone have any experience manipulating this auto-code?
 
Upvote 0

Forum statistics

Threads
1,215,194
Messages
6,123,569
Members
449,108
Latest member
rache47

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