prob with dates in VBA

D

dee

How do i say within a macro taht my dates for a workweek should be static.
like 03/Mar to 7/Mar should remain static for thsi week and when i m in next
week when i open this same sheet it shud give me last week's dates
only..(this is to maintain versions)
but the date has to be dynamic. taht is when i run a macro, when im in a
currenty week it shud show me the current week's 5 days only.... as 5 columns.
but when i open the version of teh sheet that i opened l;ast week it shud
give me last weeks dates only
 
B

Bob Phillips

Dim StartDate As Date
Dim EndDate As Date

StartDate = Date - Weekday(Date, 2) + 1
EndDate = StartDate + 4


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

dee

But how do i writ e ths peice of code so taht my column F2 to J2 get filled
with dates
 
B

Bob Phillips

Dim StartDate As Date
Dim EndDate As Date

StartDate = Date - Weekday(Date, 2) + 1
EndDate = StartDate + 4

For i = StartDate To EndDate
Cells(2, i+5).Value = i
Cells(2, i+5).Numberformat = "dd/mm/yyyy"
Next i

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top