Date problem

M

Melvin Purvis

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!
 
R

Ron Rosenfeld

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
 

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

Top