B
Ben
Hi, here is the problem I have: the macro s result is instead of inserting
the data in the cell of the next row(Range("K" & R & ""), a new column is
created each time.
Can you figured out the problem?
Do Until Cells(R, 5) = "TOTAL:"
R = 8
FrstDay = 7
LastDay = 14
Card1 = Cells(R, 4)
Sqlstring = "select sum(Temps_Arrondi) from Presence_BCV_App where
_Card= '" & Card1 & "' and ([Date] > '" & FrstDay
& "' and
_[Date] < '" & LastDay & "') "
connstring = "ODBC;DSN=DEV_DCI;UID=sa;PWD=abcde;Database=DEV_DCI"
With ActiveSheet.QueryTables.Add(Connection:=connstring,
Destination:=
_Range("K" & R),
Sql:=sqlstring)
.Refresh BackgroundQuery = False
End With
R = R + 1
Loop
the data in the cell of the next row(Range("K" & R & ""), a new column is
created each time.
Can you figured out the problem?
Do Until Cells(R, 5) = "TOTAL:"
R = 8
FrstDay = 7
LastDay = 14
Card1 = Cells(R, 4)
Sqlstring = "select sum(Temps_Arrondi) from Presence_BCV_App where
_Card= '" & Card1 & "' and ([Date] > '" & FrstDay
& "' and
_[Date] < '" & LastDay & "') "
connstring = "ODBC;DSN=DEV_DCI;UID=sa;PWD=abcde;Database=DEV_DCI"
With ActiveSheet.QueryTables.Add(Connection:=connstring,
Destination:=
_Range("K" & R),
Sql:=sqlstring)
.Refresh BackgroundQuery = False
End With
R = R + 1
Loop