MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

date function

  Asked By: Maria    Date: Oct 23    Category: MS Office    Views: 1491

I've been trying to generate a list of dates to use in a timesheet,
with a loop in vba. What has been happening is that the loop has
actually been changing the date on my pc's clock.

I had been using...

For i = 1 To 385
Range("A" & i).Value = Date
Date = Date + 1
Next i

Is this perhaps the "system" date? If so, how would I go about doing
a loop just on the timesheet?



1 Answer Found

Answer #1    Answered By: Adelbert Fischer     Answered On: Oct 23

Yes, "date" is the system  date. When you say "Date = something", you
are changing  your system date. Try looping like this:

Sub Test()
TempDate = date  - 1
For i = 1 To 385
Range("A" & i).Value = TempDate + i
Next i
End Sub

Didn't find what you were looking for? Find more on date function Or get search suggestion and latest updates.