LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default changing a recorded macro - date problem....

Hi!

I recorded a macro in Excel, downloading a range of data from our SQLserver.
I now want to change the date and timestamp I entered in the macro to a value
that a user types in a cell in Excel.

This is the VBA code:
Sub Import()
'
' Import Macro
' Macro recorded 23.09.2005 by Daan'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=SQL04;UID=Daan;APP=Microsoft Office
2003;WSID=####;DATABASE=###;Trusted_Connection=Yes " _
, Destination:=Range("A1"))
.CommandText = Array( _
"SELECT POM_Machinedata.DATUM_AKTUELL,
POM_Machinedata.TOWEINSATZGEWICHT" & Chr(13) & "" & Chr(10) & "FROM
POM.dbo.POM_Machinedata POM_Machinedata" & Chr(13) & "" & Chr(10) & "WHERE
(POM_Machinedata.DATUM_AKTUELL={ts '2005-07-13 13:25:38'} And POM_Machined" _
, _
"ata.DATUM_AKTUELL<={ts '2005-09-22 10:59:53'})" & Chr(13) & "" &
Chr(10) & "ORDER BY POM_Machinedata.DATUM_AKTUELL" _
)
.Name = "Query from SQL04"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub



Now I want to change the date '2005-07-13 13:25:38' to a cell name, for
example to the date in cell A1 and the date '2005-09-22 10:59:53' to the date
in cell A2.

By simply replacing the date by the cell name, I run into problems in the
last line (.Refresh BackgroundQuery:=False).

Any help is welcome!

Have a nice weekend,

Daan
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unique problem with recorded macro Junior[_3_] Excel Programming 2 September 19th 05 09:51 PM
Problem with a recorded macro to create two pivot tables from same data rjamison Excel Programming 0 June 14th 05 12:14 AM
Problem with a recorded macro to create two pivot tables from same data Pete Straman via OfficeKB.com[_2_] Excel Programming 1 April 20th 05 05:28 PM
how is the syntax to replace a date, recorded within a macro with a cell value ? thomipilot[_2_] Excel Programming 0 October 1st 04 12:34 PM
how is the syntax to replace a date, recorded within a macro with a cell value ? thomipilot Excel Programming 1 September 30th 04 05:18 PM


All times are GMT +1. The time now is 09:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"