Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
dwest100
 
Posts: n/a
Default How to shorten formulas??


Is there a technique to shorten formulas such as this one?

=IF(K7=TIME(0,1,30)),J7,IF(AND(K7TIME(0,1,45),K7< =TIME(0,2,10)),J7+2,IF(AND(K7TIME(0,2,10),K7<=TIM E(0,2,30)),J7+4,IF(AND(K7TIME(0,2,30),K7<=TIME(0, 2,40)),J7+6,IF(K7TIME(0,2,40),J7+10))))))


I'm always creating these spaghetti style formulas and I'd like to
learn some techniques to shorten them.

Any advice or recommendations would be greatly appreciated!


--
dwest100
------------------------------------------------------------------------
dwest100's Profile: http://www.excelforum.com/member.php...o&userid=18864
View this thread: http://www.excelforum.com/showthread...hreadid=471673

  #2   Report Post  
ScottO
 
Posts: n/a
Default

With the formula example given, you might like to create a table of
the various time span answers, and then use one of the lookup
functions or an index/match combination to select the relevant
response.
Rgds,
ScottO

"dwest100"
wrote in message
...
|
| Is there a technique to shorten formulas such as this one?
|
|
=IF(K7=TIME(0,1,30)),J7,IF(AND(K7TIME(0,1,45),K7< =TIME(0,2,10)),J7+2
,IF(AND(K7TIME(0,2,10),K7<=TIME(0,2,30)),J7+4,IF( AND(K7TIME(0,2,30)
,K7<=TIME(0,2,40)),J7+6,IF(K7TIME(0,2,40),J7+10)) ))))
|
|
| I'm always creating these spaghetti style formulas and I'd like to
| learn some techniques to shorten them.
|
| Any advice or recommendations would be greatly appreciated!
|
|
| --
| dwest100
| -------------------------------------------------------------------
-----
| dwest100's Profile:
http://www.excelforum.com/member.php...o&userid=18864
| View this thread:
http://www.excelforum.com/showthread...hreadid=471673
|


  #3   Report Post  
Roger Govier
 
Posts: n/a
Default

Hi Scott

One way would be to use a helper cell and convert all time intervals into
decimal minutes. I used cell K1 and entered
=(K7-TIME(1,30,0))*24*60
Excel stores times as fractions of a day so multiplying by 24 gives hours,
and further multiplying by 60 gives minutes.

Then your time intervals after 1:30 are 15 mins, 25, 20, 10 or cumulatively
they are 15, 40, 60 and 70 and you are adding to the value in J7 either
2,4,6 or 10
so the formula can be simplified to

=(K1=0)*J7+(K115)*2+(K140)*2+(K160)*2+(K170)* 4

where the values within the brackets will either be True or False.

Multiplying them by a number, coerces them to either 1 for True or 0 for
False so if the calculated time in minutes is greater than or equal to 0,
then it must be at least 1:30 and we use the value in J7.

The rest of the formula then adds the incremental value, depending upon how
far past 1:30 we are.


Regards

Roger Govier


ScottO wrote:
With the formula example given, you might like to create a table of
the various time span answers, and then use one of the lookup
functions or an index/match combination to select the relevant
response.
Rgds,
ScottO

"dwest100"
wrote in message
...
|
| Is there a technique to shorten formulas such as this one?
|
|
=IF(K7=TIME(0,1,30)),J7,IF(AND(K7TIME(0,1,45),K7< =TIME(0,2,10)),J7+2
,IF(AND(K7TIME(0,2,10),K7<=TIME(0,2,30)),J7+4,IF( AND(K7TIME(0,2,30)
,K7<=TIME(0,2,40)),J7+6,IF(K7TIME(0,2,40),J7+10)) ))))
|
|
| I'm always creating these spaghetti style formulas and I'd like to
| learn some techniques to shorten them.
|
| Any advice or recommendations would be greatly appreciated!
|
|
| --
| dwest100
| -------------------------------------------------------------------
-----
| dwest100's Profile:
http://www.excelforum.com/member.php...o&userid=18864
| View this thread:
http://www.excelforum.com/showthread...hreadid=471673
|


  #4   Report Post  
Roger Govier
 
Posts: n/a
Default

My Apologies Scott

I clicked on the wrong message. This was meant for dWest
Regards

Roger Govier


Roger Govier wrote:
Hi Scott

One way would be to use a helper cell and convert all time intervals
into decimal minutes. I used cell K1 and entered
=(K7-TIME(1,30,0))*24*60
Excel stores times as fractions of a day so multiplying by 24 gives
hours, and further multiplying by 60 gives minutes.

Then your time intervals after 1:30 are 15 mins, 25, 20, 10 or
cumulatively they are 15, 40, 60 and 70 and you are adding to the value
in J7 either 2,4,6 or 10
so the formula can be simplified to

=(K1=0)*J7+(K115)*2+(K140)*2+(K160)*2+(K170)* 4

where the values within the brackets will either be True or False.

Multiplying them by a number, coerces them to either 1 for True or 0 for
False so if the calculated time in minutes is greater than or equal to
0, then it must be at least 1:30 and we use the value in J7.

The rest of the formula then adds the incremental value, depending upon
how far past 1:30 we are.


Regards

Roger Govier


ScottO wrote:

With the formula example given, you might like to create a table of
the various time span answers, and then use one of the lookup
functions or an index/match combination to select the relevant
response.
Rgds,
ScottO

"dwest100"
wrote in message
...
|
| Is there a technique to shorten formulas such as this one?
|
|
=IF(K7=TIME(0,1,30)),J7,IF(AND(K7TIME(0,1,45),K7< =TIME(0,2,10)),J7+2
,IF(AND(K7TIME(0,2,10),K7<=TIME(0,2,30)),J7+4,IF( AND(K7TIME(0,2,30)
,K7<=TIME(0,2,40)),J7+6,IF(K7TIME(0,2,40),J7+10)) ))))
|
|
| I'm always creating these spaghetti style formulas and I'd like to
| learn some techniques to shorten them.
|
| Any advice or recommendations would be greatly appreciated!
|
|
| --
| dwest100
| -------------------------------------------------------------------
-----
| dwest100's Profile:
http://www.excelforum.com/member.php...o&userid=18864
| View this thread:
http://www.excelforum.com/showthread...hreadid=471673
|


  #5   Report Post  
Roger Govier
 
Posts: n/a
Default

Hi

One way would be to use a helper cell and convert all time intervals into
decimal minutes. I used cell K1 and entered
=(K7-TIME(1,30,0))*24*60
Excel stores times as fractions of a day so multiplying by 24 gives hours,
and further multiplying by 60 gives minutes.

Then your time intervals after 1:30 are 15 mins, 25, 20, 10 or cumulatively
they are 15, 40, 60 and 70 and you are adding to the value in J7 either
2,4,6 or 10
so the formula can be simplified to

=(K1=0)*J7+(K115)*2+(K140)*2+(K160)*2+(K170)* 4

where the values within the brackets will either be True or False.

Multiplying them by a number, coerces them to either 1 for True or 0 for
False so if the calculated time in minutes is greater than or equal to 0,
then it must be at least 1:30 and we use the value in J7.

The rest of the formula then adds the incremental value, depending upon how
far past 1:30 we are.

Regards

Roger Govier


dwest100 wrote:
Is there a technique to shorten formulas such as this one?

=IF(K7=TIME(0,1,30)),J7,IF(AND(K7TIME(0,1,45),K7< =TIME(0,2,10)),J7+2,IF(AND(K7TIME(0,2,10),K7<=TIM E(0,2,30)),J7+4,IF(AND(K7TIME(0,2,30),K7<=TIME(0, 2,40)),J7+6,IF(K7TIME(0,2,40),J7+10))))))


I'm always creating these spaghetti style formulas and I'd like to
learn some techniques to shorten them.

Any advice or recommendations would be greatly appreciated!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Formulas take waaaay too long... belly0fdesire Excel Worksheet Functions 7 August 8th 05 10:11 PM
Problem with named formula's nathan Excel Worksheet Functions 0 January 21st 05 04:07 PM
Formulas Stan Excel Worksheet Functions 3 January 21st 05 02:58 PM
How to make Excel run limited number of formulas on a given worksh John Excel Discussion (Misc queries) 0 January 12th 05 04:29 PM
calculating formulas for all workbooks in a folder Chad Excel Worksheet Functions 3 November 13th 04 05:22 PM


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"