I have a worksheet that I import a database query. In the columns I use week ending dates. The column header must be changed to the week ending date (A1+7).
I tried to incorporate an auto date change in the macro, but it only seems to add the 7 days to the initial column.
What I need is for column E and beyond to change by 7 days when I run this macro:
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;CollatingSequence=ASCII;DBQ=C:\;DefaultDir=C:\;Deleted=0;Driver={Driver do Microsoft dBase (*.dbf)};DriverId=533;FIL=dBase 5.0;" _
), Array( _
"MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Statistics=0;Threads=3;UserCommitSync=Yes;" _
)), Destination:=Range("D1"))
.CommandText = Array("SELECT DSERVICE.DAILY_CPT" & Chr(13) & "" & Chr(10) & "FROM DSERVICE DSERVICE")
.Name = "Query from DSERVICE_2"
.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
Range("D1").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+7"
Range("D2").Select
End Sub
TIA
I tried to incorporate an auto date change in the macro, but it only seems to add the 7 days to the initial column.
Draw.xls | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | DISTRICT | ROUTE | 12/4/2005 | 12/11/2005 | |||
2 | TC1 | 614A607C | 1 | 1 | |||
3 | TC1 | 614A609C | 3 | 3 | |||
4 | TC1 | 614A611C | 3 | 3 | |||
Sheet1 |
What I need is for column E and beyond to change by 7 days when I run this macro:
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;CollatingSequence=ASCII;DBQ=C:\;DefaultDir=C:\;Deleted=0;Driver={Driver do Microsoft dBase (*.dbf)};DriverId=533;FIL=dBase 5.0;" _
), Array( _
"MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Statistics=0;Threads=3;UserCommitSync=Yes;" _
)), Destination:=Range("D1"))
.CommandText = Array("SELECT DSERVICE.DAILY_CPT" & Chr(13) & "" & Chr(10) & "FROM DSERVICE DSERVICE")
.Name = "Query from DSERVICE_2"
.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
Range("D1").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+7"
Range("D2").Select
End Sub
TIA