Go Back   PCMech Forums > Help & Discussion > Software Discussion & Support

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 11-18-2004, 10:15 PM   #1
Mechanical Guru
 
PardeGT's Avatar
 
Join Date: Jul 2000
Location: Husker Country
Posts: 1,472
Question Excel Function ?

Is there a shorter way to write the below formula? I will need to use this similar function in many cells within a spreadsheet and was curious if there is a shorter way of typing it. Sorry, but I only know the basics and have not needed much beyond simple functions before.

=IF(A1=1,B5/1*1,IF(A1=2,B5/2*1,IF(A1=3,B5/3*1,IF(A1=4,B5/4*1,IF(A1=5,B5/5*1,IF(A1=6,B5/6*1,0))))))

Thanks for your replies.
__________________
If you really want to understand - try changing it.

Sys specs:
NZXT Lexa_Asus P5E_E6750 2.66Ghz_GSkill 2GB PC6400_Mushkin 2GB PC6400_WD SE16 250GB_Pioneer 16x slot dvd_Pioneer 16x dvdrw
Mitsumi 1.44_ATI x1600pro 512mb_Linksys WRT54GS_Samsung R237W LCD_Altec Lansing 641_WinXP PRO SP2
PardeGT is offline   Reply With Quote
Old 11-19-2004, 01:19 AM   #2
Member (10 bit)
 
PMich's Avatar
 
Join Date: Jan 2001
Location: Greenville, MS
Posts: 625
I want to make sure I understand what you are trying to do. In your destination cell (the cell you are typing the formula in) you want the value of b5 to be divided by the value in a1. If a1 is a value other than 1 to 6 you want the value in the destination cell to be zero. I don't see why you are multiplying everything by 1 so I omitted it.

=IF(1<=A1,IF(A1<=6,B5/A1,0))
In english, if 1 is less than or equal to A1 and A1 is less than or equal to 6, then the value of the destination cell is equal to B5 divided by A1. If A1 is less than 1 or greater than six then value of destination cell is zero.

You may already know this but if you are doing this in multiple cells you can lock in a reference cell, row, or column by putting a dollar sign in front of the cell name in the formula. For example:

$A$1 in a formula will refer to that cell no matter where you paste it in the spreadsheet.

$A1 will lock in the column

A$1 will lock in the row

I find this really useful when I don't want to retype or copy and paste formulas all the time. HTH
PMich is offline   Reply With Quote
Old 11-19-2004, 01:39 AM   #3
Member (9 bit)
 
HyperTF's Avatar
 
Join Date: Sep 2004
Location: Victoria, Australia
Posts: 418
How about this...

=IF(A1 >= 1, IF(A1<=6,B5/A1,0),0)

It does the same as PMich's, but if there is a possibility that the number will be less than 1 in A1 it will return a value of zero instead of FALSE.

Depends as PMich said as to the purpose!

Last edited by HyperTF; 11-19-2004 at 01:56 AM.
HyperTF is offline   Reply With Quote
Old 11-19-2004, 10:23 AM   #4
Member (10 bit)
 
PMich's Avatar
 
Join Date: Jan 2001
Location: Greenville, MS
Posts: 625
When nesting if statements in excel you only need to supply one value if any of the nested logical statements are false. The way I wrote it should return a value of zero if A1 is less than 1. HyperTF, it appears to me that the way you wrote the if statement that there are too many arguments.
PMich is offline   Reply With Quote
Old 11-19-2004, 11:43 AM   #5
Mechanical Guru
 
PardeGT's Avatar
 
Join Date: Jul 2000
Location: Husker Country
Posts: 1,472
Thanks. First of all you are right PMICH in that I do not need the *1 in each function.

Here's the situation:
What the function is trying to do is there is a primary control cell (A1) with a entered value between 1 and 6 (mon-sat). There will then be another cell (B5) with a number in it. A third cell (C1) is what the function is written for. If A1 = 1 then C1=B5, if A1 = 2 then C1 =B5/2....etc up to A1 = 6 with C1 = B5/6. I will then create a similar formula for C2,C3,C4,C5 and C6. If, for example, there are only 4 days in the week (A1 = 4) then each funtion for C1,C2,C3 and C4 will return the value of B5/4 and C5 and C6 would be zero.

Thanks for your input.
PardeGT is offline   Reply With Quote
Old 11-19-2004, 01:15 PM   #6
Member (10 bit)
 
PMich's Avatar
 
Join Date: Jan 2001
Location: Greenville, MS
Posts: 625
Now I see where you are going. The formula I wrote would be for cell C1. You can copy and paste the formula into each of the above cells and increase the minimum by 1 to do what you want so:
C2 would be =IF(2<=A1,IF(A1<=6,B5/A1,0))
C3 would be =IF(3<=A1,IF(A1<=6,B5/A1,0))
C4 would be =IF(4<=A1,IF(A1<=6,B5/A1,0))
C5 would be =IF(5<=A1,IF(A1<=6,B5/A1,0))
C6 would be =IF(A1=6,B5/A1,0))
PMich is offline   Reply With Quote
Old 11-19-2004, 11:08 PM   #7
Mechanical Guru
 
PardeGT's Avatar
 
Join Date: Jul 2000
Location: Husker Country
Posts: 1,472
Thanks for your help. I was a little wrong once I looked at my instructions. I wanted it to accumulate the results from day to day. For example, on a 4 day week C1 would return B5/4*1, C2 = B5/4*2, C3 = B5/4*3 and C4 = B5/4*4.

HyperTF appears to be correct to have ,0),0) because otherwise when A1 is less than day count...such as answer in C3 = FALSE when A1 = 2. I want it to return a 0 instead.

Just to show you what I ended up with here is the function that works correctly for C4:
=IF(4<=$A$1,IF($A$1<=6,$B$5/$A$1*4,0),0)

Thanks again.
PardeGT is offline   Reply With Quote
Old 11-20-2004, 01:06 AM   #8
Member (10 bit)
 
PMich's Avatar
 
Join Date: Jan 2001
Location: Greenville, MS
Posts: 625
Quote:
Originally Posted by PardeGT
HyperTF appears to be correct to have ,0),0) because otherwise when A1 is less than day count...such as answer in C3 = FALSE when A1 = 2. I want it to return a 0 instead.
I didn't know you could do that. Looks like I learned a little something, too. IMHO, IF statements are one of the most useful things in excel and learning to use them can make life a lot easier.
PMich is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



All times are GMT -5. The time now is 04:01 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2