Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro in Excel that will import data from a SQL Table this data I
want to be data between two dates/times. Need some code to set the two dates in two seperate cells on a worksheet and then run the macro. I have tried posting below from MegaWatt but get compile errors. Included is the original the code; ' With ActiveSheet.QueryTables.Add(Connection:= _ "ODBC;DSN=DL BATT;UID=sa;PWD=panelview900;APP=Microsoft® Query;WSID=DGD7K22J;DATABASE=SerialLinks" _ , Destination:=Range("A3")) .CommandText = Array( _ "SELECT vwOvenData.PushDateTime, vwOvenData.OvenID, vwOvenData.MaxPush1, vwOvenData.MaxPush2" & Chr(13) & "" & Chr(10) & "FROM SerialLinks.dbo.vwOvenData vwOvenData" & Chr(13) & "" & Chr(10) & "WHERE (vwOvenData.PushDateTime={ts '2007-11-29 06:00:00'} And " _ , _ "vwOvenData.PushDateTime<{ts '2007-11-30 06:00:00'})" & Chr(13) & "" & Chr(10) & "ORDER BY vwOvenData.PushDateTime" _ ) .Name = "Query from DL BATT" .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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hyperlink varaible substitution - How To | Excel Worksheet Functions | |||
Object varaible or With block variable not set? | Excel Programming | |||
assining a varaible to the value in another sheet. | Excel Programming | |||
Use varaible for worsheet name in a formule | Excel Programming | |||
Disappearance of assigned value of varaible when working with form | Excel Programming |