1 Client Company Price/Share Shares Held Value Sell At
2 Turner Hiabuv Toys $120.00 50 $6,000.00 $125.00 3 Case Tailspin Toys $89.75 120 $10,770.00 $200.00 4 Conroy Hiabuv Toys $120.00 20 $2,400.00 $175.00 5 Beauvoir Mightyflight Toys $178.00 50 $8,900.00 $250.00 6 Turner Mightyflight Toys $178.00 200 $35,600.00 $300.00 7 Lucas Peck n Order Toys $65.25 50 $3,262.50 $95.00 8 Case Hiabuv Toys $120.00 100 $12,000.00 $115.00 Sell! 9 Finn Tailspin Toys $89.75 80 $7,180.00 $90.00 10 Beauvoir Peck n Order Toys $65.25 400 $26,100.00 $80.00 11 12 13 How to Use this Sample Workbook $10,770.00 14 This workbook contains a variety of formulas that use the IF function. Many of the formulas 15 also include other functions, such as the AND, OR, SUM, AVERAGE, and COUNT functions. 16 Column H contains the sample formulas. To see all the formulas, scroll through this 17 workbook. Cells with light green backgrounds contain valid formulas; cells with aqua 18 backgrounds contain invalid formulas or formulas that demonstrate another way (but not necessarily the best way) to perform the same task. 19 20 You can make changes to the values in the above table, and you can also experiment with the formulas in column H. However, it is recommended that you do not save changes to this Good! 21 workbook. If you must save changes, click Save As on the File menu and give the file a new 22 name before you save it. 23 24 25 26 27 28 29 30 Good! 31 32 Good! 33 34 35 36 37 38 39 40 41 42 43 44 Good! 45 46 Good! 47 48 49 A B C D E F G H 50 51 52 53 54 55 56 57 58 Good! 59 60 Good! 61 62 63 64 65 66 67 68 69 70 71 Good! 72 73 74 75 76 77 78 79 80 81 82 83 $41,600.00 84 85 #N/A 86 87 88 89 90 91 92 93 94 95 96 $22,770.00 97 98 A B C D E F G H 99 100 101 102 103 104 105 106 107 108 109 110 2 111 112 2 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 2 128 129 130 131 132 133 134 135 136 137 138 139 140 56.6666666667 141 142 17 143 144 145 146 147 A B C D E F G H 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 120 164 165 200 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 420 185 186 50 187 188 189 190 191 192 193 194 195 196 I J K L M N 1 2 Example 1: Simple IF Formula 3 The formula in cell H2 displays "Sell!" if 4 the value in cell C2 is greater than or 5 equal to the value in cell F2. 6 The formula has been filled down into 7 cells H3:H10. Note that because cell C8 contains a value that is greater than the 8 value in cell F8, cell H8 displays the text 9 string "Sell!" 10 11 12 13 Example 2: Simple IF Formula 14 The formula in cell H13 displays the 15 greater of the values in cells E2 and E3. 16 Because cell E3 contains a greater value, that value is displayed. 17 18 19 20 21 Example 3: Longer IF Formula 22 The formula in cell H21 displays either 23 "Great!," "Good!," "OK," or "Bad!" 24 depending on the value in cell C2. Because C2 has a value of $120.00, the 25 formula returns "Good!" 26 27 28 29 30 Examples 4 and 4a: Using AND with IF 31 in a Formula
32 The formula in cell H30 displays the word
33 "Good!" if both conditions in the AND function are true. Otherwise, the word 34 "Bad!" is displayed. 35 Note that the formula in cell H32 does not 36 use the AND function. Because of this, the 37 formula is slightly more complicated and 38 more difficult to understand.
39 40 41 42 43 44 Examples 5 and 5a: Using OR with IF in 45 a Formula
46 The formula in cell H44 displays the word
47 "Good!" if either of the conditions in the OR function are true. Otherwise, the word 48 "Bad!" is displayed. 49 Note that the formula in cell H46 does not use the OR function. Because of this, the formula is slightly more complicated and more difficult to understand. Examples 5 and 5a: Using OR with IF in a Formula
The formula in cell H44 displays the word
"Good!" if either of the conditions in the OR function are true. Otherwise, the word "Bad!" is displayed. I J K L M N Note that the formula in cell H46 does not 50 use the OR function. Because of this, the 51 formula is slightly more complicated and more difficult to understand. 52 53 54 55 56 57 58 Examples 6 and 7: Using Boolean Operators with the IF Function 59 60 The formula in cell H58 uses the "*" 61 Boolean operator in place of the AND function. Functionally, this formula is 62 identical to the formula in cell H44. 63 The formula in cell H60 uses the "+" 64 Boolean operator in place of the OR 65 function. Functionally, this formula is identical to the formula in cell H46. 66 67 68 69 70 71 Example 8: A More Complicated Example of Boolean Operators and the 72 IF Function 73 74 The formula in cell H71 uses both the "*" and "+" Boolean operators in place of the 75 AND and OR functions. 76 To make the formula return "Bad!," 77 change either of the values in cells D2 78 and D3. 79 80 81 Examples 9 and 9a: Proper and 82 Improper Array Formulas 83 84 The array formula in cell H83 refers to two ranges that both contain the same number 85 of cells, so the formula returns a valid 86 result. The array formula in cell H85 refers to two ranges that contain a different 87 number of cells, so the formula returns an 88 error value. 89 Note After you modify an array formula, 90 click after the formula and press 91 CTRL+SHIFT+ENTER (under Windows) or COMMAND+ENTER. 92 93 94 95 96 Example 10: A Simple Array Formula 97 Using SUM and IF (a SUM-IF Formula)
98 The array formula in cell H96 checks each
cell in the range A1:A10 to see if it contains the text string "Case." For each cell that contains this string, the matching cell in the range E1:E10 is added to the total.
This allows you to calculate the value of
Case's portfolio. Example 10: A Simple Array Formula Using SUM and IF (a SUM-IF Formula)
I J K formula inLcell H96 checks
The array M each N 99 cell in the range A1:A10 to see if it contains the text string "Case." For each 100 cell that contains this string, the matching 101 cell in the range E1:E10 is added to the total. 102 103 This allows you to calculate the value of Case's portfolio. 104 105 106 107 108 109 110 Examples 11 and 11a: More Simple Array Formulas Using SUM and IF (a 111 SUM-IF Formula) 112 113 The array formula in cell H110 checks each cell in the range A1:A10 to see if it 114 contains the text string "Turner." For each 115 cell that contains this string, 1 is added to the total. 116 117 This allows you to count the number of cells in a range that contain a specified 118 value or text string. 119 120 The array formula in cell H112 returns exactly the same value, since adding zero 121 to a total doesn't change the total. 122 123 124 125 126 127 Example 12: Using COUNT and IF in an 128 Array Formula
129 The array formula in cell H127 counts the
130 number of cells in the range B1:B10 that contain the text string "Mightyflight Toys." 131 132 Note Adding ",0" to this formula causes it to return an incorrect result! Be careful 133 when you add ",0" to an array formula. 134 135 136 137 138 139 140 Examples 13 and 13a: Using AVERAGE 141 and IF in an Array Formula
142 The array formula in cell H140 checks
143 each cell in the range B1:B10 to see if it contains the text string "Hiabuv Toys." If it 144 does, the matching cell in the range 145 D1:D10 is added to the AVERAGE function. As a result, the formula returns 146 the average number of shares in all 147 Hiabuv Toys portfolios. There are three Hiabuv Toys portfolios that contain a combined total of 170 shares, so the average is 170/3, or 56.6667 shares.
The array formula in cell H142 does the
same thing, but because it contains ",0" it returns the average number of Hiabuv Toys shares in all portfolios. 170/10 = 17. and IF in an Array Formula
The array formula in cell H140 checks
each cell in the range B1:B10 to see if it contains the text string "Hiabuv Toys." If it does, the matching cell in the range D1:D10 is added to the AVERAGE function. As a result, the formula returns the average number of shares in all I J HiabuvK Toys portfolios. L There are three M N Hiabuv Toys portfolios that contain a 148 combined total of 170 shares, so the 149 average is 170/3, or 56.6667 shares. 150 The array formula in cell H142 does the 151 same thing, but because it contains ",0" it 152 returns the average number of Hiabuv Toys shares in all portfolios. 170/10 = 17. 153 154 155 156 157 158 159 160 161 162 163 Examples 14 and 15: Using MAX/MIN and IF in an Array Formula 164 165 The array formula in cell H163 checks 166 each cell in the range B1:B10 to see if it contains the text string "Tailspin Toys." 167 The MAX function is then applied to the 168 matching cells in the range D1:D10, and the largest value is returned. So, the 169 formula returns the largest number of 170 shares in any of the Tailspin Toys portfolios. 171 172 The array formula in cell H165 checks 173 each cell in the range D1:D10 to see if its value is greater than 150. The MIN 174 function is then applied to all such values. 175 So, the formula returns the smallest value in the range D1:D10 that is greater than 176 150. 177 178 179 180 181 182 183 184 Examples 16 and 17: Using Boolean 185 Operators, SUM, and IF in an Array Formula 186 187 The array formula in cell H184 uses the "+" Boolean operator to check each cell in 188 the range B1:B10 for the text strings 189 "Hiabuv Toys" OR "Mightyflight Toys." For each cell that contains either of these two 190 strings, the matching cell in D1:D10 is 191 added to the result. Therefore, the formula 192 returns the combined number of Hiabuv Toys and Mightyflight Toys shares owned 193 by all of your clients. 194 The array formula in cell H186 uses the 195 "*" Boolean operator to determine how 196 many shares of Hiabuv Toys are owned by Turner. strings, the matching cell in D1:D10 is added to the result. Therefore, the formula returns the combined number of Hiabuv Toys and Mightyflight Toys shares owned by all of your clients.
The array formula in cell H186 uses the
"*" Boolean operator to determine how I J manyKshares of Hiabuv L Toys are owned M N by Turner. 197 198 199 200 201 202 203