ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date problem (https://www.excelbanter.com/excel-programming/428424-date-problem.html)

Melvin Purvis[_2_]

Date problem
 
Hello,

I am using a variable to delete rows in a large spreadsheet.

Dim StartDate As Date
Dim EndDate As Date
StartDate = Now
EndDate = Workday(StartDate, 1)

I need to change EndDate so that whatever StartDate is, EndDate is the 2nd
Friday after that, unless StartDate is a Friday, in which case I need
EndDate to be the 1st Friday after that.

Can anybody change my verbage into the code needed? I've been struggling
with it for awhile now.

Many thanks in advance!



Ron Rosenfeld

Date problem
 
On Wed, 13 May 2009 08:56:46 -0500, "Melvin Purvis" wrote:

Hello,

I am using a variable to delete rows in a large spreadsheet.

Dim StartDate As Date
Dim EndDate As Date
StartDate = Now
EndDate = Workday(StartDate, 1)

I need to change EndDate so that whatever StartDate is, EndDate is the 2nd
Friday after that, unless StartDate is a Friday, in which case I need
EndDate to be the 1st Friday after that.

Can anybody change my verbage into the code needed? I've been struggling
with it for awhile now.

Many thanks in advance!



EndDate = StartDate + 14 - Weekday(StartDate + 1, vbSunday)

--ron

Melvin Purvis[_2_]

Date problem
 
Brilliant! Thanks again.

"Ron Rosenfeld" wrote in message
...


EndDate = StartDate + 14 - Weekday(StartDate + 1, vbSunday)

--ron




Ron Rosenfeld

Date problem
 
On Wed, 13 May 2009 10:33:25 -0500, "Melvin Purvis" wrote:

Brilliant! Thanks again.


You're welcome. Glad to help. Thanks for the feedback.
--ron


All times are GMT +1. The time now is 02:55 AM.

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