Auto Change Date

circpro

New Member
Joined
Jun 27, 2004
Messages
11
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.
Draw.xls
ABCDE
1DISTRICTROUTE12/4/200512/11/2005
2TC1614A607C11
3TC1614A609C33
4TC1614A611C33
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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You need to put the formula there too, so...
Code:
Range("D1").Select 
ActiveCell.FormulaR1C1 = "=RC[-1]+7" 
Range("D2").Select 
ActiveCell.FormulaR1C1 = "=RC[-1]+7"
 
Upvote 0

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top