Looping through a series of cells with dates, need to compute from the
given date the date of the following Friday. If the given date *is*
Friday, I need that date returned, not the date of the Friday of the
following week.
Thanks.
Well, Weekday(Date) will return an integer to represent the day of the week, so you can just use a 'Case' structure to vary the response based on the current day fo the week can't you (IF today is Monday, then return today + 5 etc...)
Remember, unless you specify otherwise, Weekday(Date) will return 1 for Sunday, 2 for Monday etc...
If you need code, I can find some for you...
Regards,
Gareth
Try
=A1+CHOOSE(WEEKDAY(A1),5,4,3,2,1,0,6)
where A1 is your starting date.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"EdStevens" <quetico_man@yahoo.com> wrote in message
news:1150115227.608532.197970@y43g2000cwc.googlegroups.com...
> Looping through a series of cells with dates, need to compute
> from the
> given date the date of the following Friday. If the given date
> *is*
> Friday, I need that date returned, not the date of the Friday
> of the
> following week.
>
> Thanks.
>
Ignore mine! Chip know best!
I think I'll impliment this in some of my own code...
you said looping so here is a looping macro
Sub iffriday()
For Each c In Selection
If Application.Weekday(c) = 6 Then MsgBox c.Address
Next
End Sub
--
Don Guillett
SalesAid Software
dguillett1@austin.rr.com
"EdStevens" <quetico_man@yahoo.com> wrote in message
news:1150115227.608532.197970@y43g2000cwc.googlegroups.com...
> Looping through a series of cells with dates, need to compute from the
> given date the date of the following Friday. If the given date *is*
> Friday, I need that date returned, not the date of the Friday of the
> following week.
>
> Thanks.
>
=A1+6-WEEKDAY(A1)
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"EdStevens" <quetico_man@yahoo.com> wrote in message
news:1150115227.608532.197970@y43g2000cwc.googlegroups.com...
> Looping through a series of cells with dates, need to compute from the
> given date the date of the following Friday. If the given date *is*
> Friday, I need that date returned, not the date of the Friday of the
> following week.
>
> Thanks.
>
Just another option:
=A1+MOD(138612,WEEKDAY(A1)+6)
--
HTH. :>)
Dana DeLouis
Windows XP, Office 2003
"EdStevens" <quetico_man@yahoo.com> wrote in message
news:1150115227.608532.197970@y43g2000cwc.googlegroups.com...
> Looping through a series of cells with dates, need to compute from the
> given date the date of the following Friday. If the given date *is*
> Friday, I need that date returned, not the date of the Friday of the
> following week.
>
> Thanks.
>
Chip Pearson wrote:
> Try
>
> =A1+CHOOSE(WEEKDAY(A1),5,4,3,2,1,0,6)
>
> where A1 is your starting date.
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> Pearson Software Consulting, LLC
> www.cpearson.com
>
> "EdStevens" <quetico_man@yahoo.com> wrote in message
> news:1150115227.608532.197970@y43g2000cwc.googlegroups.com...
> > Looping through a series of cells with dates, need to compute
> > from the
> > given date the date of the following Friday. If the given date
> > *is*
> > Friday, I need that date returned, not the date of the Friday
> > of the
> > following week.
> >
> > Thanks.
> >
Perfect. Thank you.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks