# 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

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

Try

=TODAY()+13-MOD(WEEKDAY(TODAY()),7)

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())))

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1