Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Shorting the Code

Can this code be shortened? It's goes up by a fixed amount everytime
so i thought there might be a way. I have to go all the way up to
1,000,000...thats why i'm asking.

=IF($C$5<20001,6,IF($C$5<40000,12,IF($C$5<60000,18 ,IF($C
$5<80000,24,IF($C$5<100000,30,IF($C$5<120000,36,IF ($C$5<140000,42,IF($C
$5<160000,48,0))))))))

Thanks for the help,
Keith
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Shorting the Code

Keith,

Somewhere out of the way create a table like this. Note the left column is
sorted and in my case in columns A & B

Col A Col B
0 6
40000 12
60000 18
80000 24
100000 30

Then use the formula
=VLOOKUP(C5,A1:B5,2,TRUE)
Make the table the size uo want and alter the formula range to match that
table size

Mike

"Keith" wrote:

Can this code be shortened? It's goes up by a fixed amount everytime
so i thought there might be a way. I have to go all the way up to
1,000,000...thats why i'm asking.

=IF($C$5<20001,6,IF($C$5<40000,12,IF($C$5<60000,18 ,IF($C
$5<80000,24,IF($C$5<100000,30,IF($C$5<120000,36,IF ($C$5<140000,42,IF($C
$5<160000,48,0))))))))

Thanks for the help,
Keith

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Shorting the Code


Test this one...
=IF(C5<20001,6,(ROUNDDOWN(C5/20000,0))*6+6)
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Keith"
wrote in message
Can this code be shortened? It's goes up by a fixed amount everytime
so i thought there might be a way. I have to go all the way up to
1,000,000...thats why i'm asking.

=IF($C$5<20001,6,IF($C$5<40000,12,IF($C$5<60000,18 ,IF($C
$5<80000,24,IF($C$5<100000,30,IF($C$5<120000,36,IF ($C$5<140000,42,IF($C
$5<160000,48,0))))))))

Thanks for the help,
Keith
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Shorting the Code

On Feb 5, 3:08*pm, Mike H wrote:
Keith,

Somewhere out of the way create a table like this. Note the left column is
sorted and in my case in columns A & B

Col A * * * *Col B
0 * * * 6
40000 * 12
60000 * 18
80000 * 24
100000 *30

Then use the formula
=VLOOKUP(C5,A1:B5,2,TRUE)
Make the table the size uo want and alter the formula range to match that
table size

Mike



"Keith" wrote:
Can this code be shortened? It's goes up by a fixed amount everytime
so i thought there might be a way. I have to go all the way up to
1,000,000...thats why i'm asking.


=IF($C$5<20001,6,IF($C$5<40000,12,IF($C$5<60000,18 ,IF($C
$5<80000,24,IF($C$5<100000,30,IF($C$5<120000,36,IF ($C$5<140000,42,IF($C
$5<160000,48,0))))))))


Thanks for the help,
Keith- Hide quoted text -


- Show quoted text -


It works like a charm.

Thanks
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
operator statements, shorting when reusing one of the statements? KR Excel Programming 1 August 4th 05 06:20 PM


All times are GMT +1. The time now is 07:33 PM.

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

About Us

"It's about Microsoft Excel"