- Excel Champion Consulting

advertisement

Advanced Formulas & Tips Cheat Sheet

Multi-Conditional Count/Sum:

(Count)

Synt. =SUMPRODUCT(--(Rng_1=Val1), --(Rng_2=Val2))

ex. =SUMPRODUCT(--(A2:A100 = “abcd”), --(B2:B100 = 1234))

(Sum)

Synt. =SUMPRODUCT(--(Rng_1=Val1), --(Rng_2=Val2), Rng_to_Sum)

ex. =SUMPRODUCT(--(A2:A100 = “abcd”), --(B2:B100 = 1234), H2:H100)

Important : All ranges must be of equal size. Also, cannot use whole-column ranges such as A:A.

Note : Multi-Conditional Count and Sum can be accomplished with a Pivot Table but for dynamic spreadsheet design these formulas are excellent (but memory hogs.) Also, up to 30 conditions when counting, 29 conditions when summing (plus one range to sum.)

INDEX/MATCH Combination (HLOOKUP/VLOOKUP alternative):

Synt. =INDEX(Rng, MATCH(Val_to_Look_up, Lookup_Rng, [0 or 1]), [Col_Number])

ex. =INDEX(A:C,MATCH(“abcd”,A:A, 0), MATCH(123,1:1, 0))

Note : The “[ ]” in Excel means that this argument is optional.

Explantion: This is more versatile than HLOOKUP/VLOOKUP. With the INDEX/MATCH combination you can use it as a substitute for HLOOKUP or VLOOKUP, -or-, it can be used to look across columns and down rows for a value, as the above example illustrates. So, the above formula will look down column A until it finds “abcd” and then it will look across columns in row

1 until it finds the value 123. It will then return the value at the “abcd”/123 intersection.

Determine Last Used Row:

(Numeric)

ex. =INDEX(A:A, MATCH(9.99999999999999E+307,B:B))

(Alpha)

ex. =INDEX(A:A,MATCH(REPT(“z”,255),B:B))

Using Last Used Row in a Formula:

ex. =SUM(A2:INDEX(A:A,MATCH(9.99999999999999E+307,B:B))) or

ex. =SUM(A2: INDEX(A:A,MATCH(REPT(“z”,255),B:B)))

Note : This technique is important for faster formula calculation, as in when performing multiconditional Counts and Sums because you want to use the smallest range possible. Also, aids in dynamic spreadsheet design because the ranges don’t need to be manually altered.

Unique Value Counting

Synt. =SUMPRODUCT((Rng_1<>"")/COUNTIF(Rng_1, Rng_1&""))

ex. =SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100,A2:A100&""))

Note : Use the smallest range possible due to slow calculation times. See Using Last Used Row in

a Formula above.

Advanced cont.

Conditional Count/Sum Across Multiple Sheets

1.

On the Worksheet Menu Bar go to Insert/ Name/ Define

2.

In the “Names in workbook:” inputbox, type: Shts.

3.

In the “Refers to:” inputbox, type: ={“Sheet1”, “Sheet2”, “Sheet3”} (use the actual names of the worksheets.)

4.

Now you can use the following formulas to conditionally count or sum across worksheets:

ex. =SUMPRODUCT(COUNTIF(INDIRECT(Shts&"!A:A"),">0")) or ex.

=SUMPRODUCT(SUMIF(INDIRECT(Shts&"!A:A"),">100",INDIRECT(Shts&"!A:A")))

Multi-Key or Multi-condition VLOOKUP (will also work for the INDEX/MATCH comb.)

1.

Create a column in your Lookup table and concatenate the values you wish to look up (must be the column furthest to the left of the data to return if using VLOOKUP.)

2.

Now you can look up multiple keys using the following formula as an example:

Synt. =VLOOKUP(key_1 & “@” & key_2, Rng_to_Lookup, Col_Ind, [0 or 1])

ex. =VLOOKUP(A1&”@”&B1,Sheet1!A:C,3,0)

Note: There is a “@” in the middle of the two keys/conditions. This is to avoid errors such as concatenating two different records that form the same value. For instance 12A and BC equals

12ABC; 12 and ABC equals 12ABC. Two very different records equal the same key when concatenated. Using the “@” between the keys helps avoid this error.

Highlight Duplicates in a List

1.

On the Worksheet Menu Bar go to Format/ Conditional Formatting…

2.

Choose “Formula is” in the dropdown box.

3.

Type the formula:

ex. =COUNTIF(A:A, A1) > 1

4.

Click the Format button and choose the Patterns tab.

5.

Choose a color and click Ok, and then click Ok again.

Download