# Can I turn a formula into a custom function to shorten it?

1. ## Can I turn a formula into a custom function to shorten it?

I have entered the following into a cell so that it always gives me the date of the Friday of the week after the current week.

=TODAY()+IF(TEXT(TODAY(),"ddd")="Sat",13,IF(TEXT(TODAY(),"ddd")="Sun",12,IF(TEXT(TODAY(),"ddd")="Mon",11,IF(TEXT(TODAY(),"ddd")="Tue",10,IF(TEXT(TODAY(),"ddd")="Wed",9,IF(TEXT(TODAY(),"ddd")="Thu",8,IF(TEXT(TODAY(),"ddd")="Fri",7,0)))))))

It is rather long and I read that you can create custom functions.

I tried entering

Function NextFriday()

=TODAY()+IF(TEXT(TODAY(),"ddd")="Sat",13,IF(TEXT(TODAY(),"ddd")="Sun",12,IF(TEXT(TODAY(),"ddd")="Mon",11,IF(TEXT(TODAY(),"ddd")="Tue",10,IF(TEXT(TODAY(),"ddd")="Wed",9,IF(TEXT(TODAY(),"ddd")="Thu",8,IF(TEXT(TODAY(),"ddd")="Fri",7,0)))))))

End Function

When I type =NextFriday into a cell (NextFriday appeared in the list of functions which was encouraging!)
I get #NAME?

I am very new to all this so can anyone help?

Thank you  Register To Reply

2. ## Re: Can I turn a formula into a custom function to shorten it?

Try

=TODAY()+13-MOD(WEEKDAY(TODAY()),7)  Register To Reply

3. ## Re: Can I turn a formula into a custom function to shorten it?

try this
=IF(WEEKDAY(TODAY())=6,TODAY()+7,TODAY()+(6-WEEKDAY(TODAY())))  Register To Reply