If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Excel "IF" Statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-31-03, 20:34
Dave Sheaffer Dave Sheaffer is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
Excel "IF" Statement

If the numeric value in a given cell falls within a predefined range (500 to 1000), I want the value to be multiplied by a constant value (0.05). If the criteria is not met, I want the cell identified as the recipient of this action to reflect a value of 0.00.

Would someone please show me what this formula should look like? Certainly would appreciate it.
Reply With Quote
  #2 (permalink)  
Old 12-31-03, 22:24
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Immediate solution:
Assume your target cell is D1, then in E1 put this formula:

=IF(500<D1<1000,D1*0.05,0.00)

(to get the two digit display for the "false" portion, you will have to format the cell that way. Right click cell, choose Format Cell, Number (tab), then choose "Number in the left, and two decimals on the right side. Click OK.

Better Solution

It might also work better to put the following numbers into these cells and use the corresponding formula:

A1 = 500
B1= 1000
C1 = 0.05
D1 (target cell)
E1 (formula)

=IF(AND(D1>A1)*(D1<B1),D1*C1,0.00)

The reason for doing it this way is that if you reference these values in several formulas, you only have to change A1, B1, C1, rather than searching through every formula.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 12-31-03, 23:26
Dave Sheaffer Dave Sheaffer is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks a ton....works great! I really appreciate
you taking the time to respond.

Dave





Quote:
Originally posted by shades
Immediate solution:
Assume your target cell is D1, then in E1 put this formula:

=IF(500<D1<1000,D1*0.05,0.00)

(to get the two digit display for the "false" portion, you will have to format the cell that way. Right click cell, choose Format Cell, Number (tab), then choose "Number in the left, and two decimals on the right side. Click OK.

Better Solution

It might also work better to put the following numbers into these cells and use the corresponding formula:

A1 = 500
B1= 1000
C1 = 0.05
D1 (target cell)
E1 (formula)

=IF(AND(D1>A1)*(D1<B1),D1*C1,0.00)

The reason for doing it this way is that if you reference these values in several formulas, you only have to change A1, B1, C1, rather than searching through every formula.
Reply With Quote
  #4 (permalink)  
Old 12-31-03, 23:29
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Smile

Glad that it worked, and happy to help.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #5 (permalink)  
Old 01-09-04, 15:54
mdr02125 mdr02125 is offline
Registered User
 
Join Date: Oct 2003
Location: Boston, Mass. USA
Posts: 81
Shades

this was great - thanks!
I didn't realize you could compare two values in one if statement in excel.

---------------------
A1 = 500
B1= 1000
C1 = 0.05
D1 (target cell)
E1 (formula)

=IF(AND(D1>A1)*(D1<B1),D1*C1,0.00)
---------------------

I have often done nested if statements to get this result.

I have also tried unsuccessfully to write it this way:
=IF((D1>A1) AND (D1<B1),D1*C1,0.00)

Excel 2000 Help doesn't seem to provide any info on syntax for combining such expressions instead of nesting if statements. Do you (or anyone) know any where to get info on excel syntax for this?


Thanks!
Reply With Quote
  #6 (permalink)  
Old 01-09-04, 17:06
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Quote:
Originally posted by mdr02125
Shades

this was great - thanks!
I didn't realize you could compare two values in one if statement in excel.

---------------------
A1 = 500
B1= 1000
C1 = 0.05
D1 (target cell)
E1 (formula)

=IF(AND(D1>A1)*(D1<B1),D1*C1,0.00)
---------------------

I have often done nested if statements to get this result.

I have also tried unsuccessfully to write it this way:
=IF((D1>A1) AND (D1<B1),D1*C1,0.00)

Excel 2000 Help doesn't seem to provide any info on syntax for combining such expressions instead of nesting if statements. Do you (or anyone) know any where to get info on excel syntax for this?


Thanks!
I bought the book MS Excel 2000 Formulas by John Walkenbach. One of the best investments I have made. You can pick up a used copy on Amazon for about $15.

700 pages of most types of formulas and combinations; plus expanding into array formulas. And he also shows what you might think "should" work, but doesn't and why. He also includes several chapters on writing UDF (User Defined Functions) through VBA.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums

Last edited by shades; 01-09-04 at 17:08.
Reply With Quote
  #7 (permalink)  
Old 01-09-04, 17:14
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Quote:
Originally posted by mdr02125
Shades

this was great - thanks!
I didn't realize you could compare two values in one if statement in excel.

You can add even more conditions.

=IF(AND(First test)*(Second Test)*(Third Test),.....)

You can also nest IF statements within IF statements (up to seven nested IF's - although there are work-arounds for even that).

And even more powerful formula is SUMPRODUCT, which can do things like summing with multiple conditions (SUMIF can handle only one condition), and even count items based on several criteria. But SUMPRODUCT will cost in terms of processing calculation time if there are many to do.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #8 (permalink)  
Old 01-09-04, 17:40
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
BTW, I am still learning this whole thing about Formulas and what can and cannot be done.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #9 (permalink)  
Old 01-09-04, 19:18
mdr02125 mdr02125 is offline
Registered User
 
Join Date: Oct 2003
Location: Boston, Mass. USA
Posts: 81
Thanks!
Attached Images
File Type: gif thankyou anim.gif (6.6 KB, 1481 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On