NBartomeli
Programmer
can someone point me to a quick tutorial, or give me some of the basic excel commands. everything I have tried so far has not worked. thanks in advance for any help
-Nick
-Nick
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub EditedQuery()
'
' Macro1 Macro
' Macro recorded 24/07/2003 by Loomah
'
' Extracts Customer data from northwind2000
' only records for uk and canada customers returned
Dim sqlState As String
Dim Connect As String
Connect = "ODBC;DSN=MS Access Database;" & _
"DBQ=C:\Program Files\Microsoft Office\Office\Samples\Northwind2000.mdb;" & _
"DefaultDir=C:\Program Files\Microsoft Office\Office\Samples;" & _
"DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;))"
sqlState = "SELECT Customers.CompanyName, Customers.Address, Customers.City, Customers.PostalCode, Customers.Country" & vbCrLf & _
"FROM `C:\Program Files\Microsoft Office\Office\Samples\Northwind2000`.Customers Customers" & vbCrLf & _
"WHERE (Customers.Country='UK') OR (Customers.Country='Canada')" & vbCrLf & "ORDER BY Customers.CompanyName"
With Worksheets("Data").QueryTables.Add(Connection:=Connect, Destination:=Worksheets("Data").Range("A1"))
.CommandText = sqlState
.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub