ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   prob with dates in VBA (https://www.excelbanter.com/excel-discussion-misc-queries/178637-prob-dates-vba.html)

DEE

prob with dates in VBA
 
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



Bob Phillips

prob with dates in VBA
 
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)

"dee" wrote in message
...
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






DEE

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

"Bob Phillips" wrote:

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)

"dee" wrote in message
...
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







Bob Phillips

prob with dates in VBA
 
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)

"dee" wrote in message
...
But how do i writ e ths peice of code so taht my column F2 to J2 get
filled
with dates

"Bob Phillips" wrote:

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)

"dee" wrote in message
...
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










All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com