Вы находитесь на странице: 1из 181

Vic Mackie

Danny Sofer
Curtis Lemanski
Jon Kavanaugh

Content Page
Topic
1
2
3 Formula to Count like being Autofiltered
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#REF! Go
#REF! Go
Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

New
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!

Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go

N
N

E
E

43
44
45
46
47
48
49
50
51
52
53
54
55

E
E

Explanation Added
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!

Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go
Go

<-back

Hyperlink to Another sheet By Matching A Text

Let's say I want to put a link in C4 to find whatever's in B4 under another worksheet name
Curtis Lemanski

Link

Using "#" was suggested by Tony Valko

="#"&"Ref!"
The "#" sign is to refer to refer to the file the formula is on.
It is then to be joined with the sheet name we are going to link it to ("Ref")
To link it to a cell reference, we need an exclaimation mark after the worksheet name & th

=ADDRESS(MATCH(B5,Ref!A1:A15,0),1)
The ADDRESS formula helps us return a cell reference by providing the row number & colu
row_num is obtained by using the MATCH formula & column number is "1", referring to Col
MATCH formula uses "Curtis Lemanski" as a "lookup_value" to find in "lookup_array", Ref!A
Using the "&", we combine the "#", "!" and the cell reference to form this:
"#Ref!$A$6"
The 2nd part of the HYPERLINK formula is to show a name for the hyperlink.

other worksheet named "Ref".

ted by Tony Valko

worksheet name & the cell we are looking for.

he row number & column number.


is "1", referring to Column A.
"lookup_array", Ref!A1:A15. It looks for an exact match by indicating "0" & returns the row numbe

perlink.

rns the row number.

<-back

Return Unique Values in a List


From a list of duplicate names, it will only pick it once.
Fruits
Apple
Apple
Orange
Pear
Orange
Mango

Original

Tweak
Apple
Orange
Pear
Mango

Apple
Orange
Pear
Mango
0
0

0
0

Tweak is customised to my liking. I don't see the need to start 1 cell empty before applyin
In cell C6, the COUNTIF formula starts by only picking the range $E$5:E5. The criteria is th
The MATCH formula finds "0" in my results & return row "1" because that's the 1st "0" that
In Cell C7, the formula of COUNTIF expanded to $E$5:E6. Now it picks up "Tweak" & "Appl
appeared in rows 1 & 2.
The MATCH formula finds "0" again & returns row 3 this time because the 3rd one in the re
It goes on until the results for the COUNTIF returns "1" for all & it cannot find a "0". This w
Source:

http://www.exceltip.com/st/Retrieving_Unique_Values_From_A_List/805.html

pty before applying the formula.


. The criteria is the List & so it looks the whole list for "Tweak" & it all returns "0".
's the 1st "0" that appeared.
p "Tweak" & "Apple". The results will then return {1;1;0;0;0;0;0} because "Apple"

e 3rd one in the result is "0".


find a "0". This will then return #N/A.

<-back

Formula to Count like being Autofiltered


Selection

Age Group
20 - 24
25 - 29
30 - 34
35 - 39

Database

Count
2
2
2
4

Occupation Count
Doctor
4
Lawyer
3
Police
1
Accountant
2
Interest
Sports
Music
Movies

Solution by JosephP

Count
5
2
3

Cell Link

1
1
1
1

1
1
1
1

1
1
1

Age Group
35 - 39
35 - 39
20 - 24
30 - 34
25 - 29
35 - 39
20 - 24
25 - 29
30 - 34
35 - 39

Occupation
Doctor
Accountant
Lawyer
Lawyer
Doctor
Accountant
Doctor
Lawyer
Police
Doctor

ution by JosephP
Explanation for F3

Interest
Music
Sports
Sports
Sports
Movies
Music
Movies
Sports
Movies
Sports

($J$3:$J$12=E3)
0
0
1
0
0
0
1
0
0
0

1 or 0
0
0
1
0
0
0
1
0
0
0

1st
1st
2nd
MATCH ISNUMBER
MATCH
Formula Formula
1 or 0 Formula
1
1
1
2
4
1
1
1
2
1
1
1
2
1
1
1
1
1
1
3
4
1
1
2
1
1
1
3
2
1
1
1
3
1
1
3
1
1
1
1

2nd
ISNUMBER
Formula
1 or 0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

End Result
0
0
1
0
0
0
1
0
0
0
Total for F3

<-back

Return Multiple values for same criteria


From a list of duplicate names, it will only pick it once.
Fruits
Apple
Apple
Orange
Pear
Orange
Mango
Apple

Price
$0.50
$0.80
$1.00
$0.75
$0.90
$3.00
$0.75

Fruits
Price 1
Price 2
Price 3
Apple
$0.50
$0.80
$0.75
Orange
$1.00
$0.90
#VALUE!
Pear
$0.75
#VALUE! #VALUE!
Mango
$3.00
#VALUE! #VALUE!
#N/A
#N/A
#N/A
#N/A

$E6=$B$6:$B$12
This returns TRUE & FALSE for the range of B6:B12. {TRUE;TRUE;FALSE;FALSE;FALSE;FALS
ROW($B$6:$B$12)
It will state the row number B6:B12 is at. {6;7;8;9;10;11;12}
By adding a MIN formula in front of the ROW formula, it takes 6, the MIN of 6-12.
And by subtracting the 1st ROW formula with the 2nd one together with MIN, it becomes {
1 is then added at the end to make it {1;2;3;4;5;6;7}
Together with the TRUE & FALSE formula, the array for the SMALL formula is {1;2;"";"";"";"
Price 1 will choose to look at row 1 of B6:B12 because of the formula COLUMN (A1)
Source:

http://www.get-digital-help.com/2009/10/25/how-to-return-multiple-values-using-vlookup-in

Price 4
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#N/A

FALSE;FALSE;FALSE;TRUE}

of 6-12.
MIN, it becomes {0;1;2;3;4;5;6}

a is {1;2;"";"";"";"";7}
LUMN (A1)

ues-using-vlookup-in-excel/

<-back

Sort Unique Values in separate list

nicole
Ben
Alan
Rachel
Alan
Phoebe

Sorted Unique List


Alan
Ben
nicole
Phoebe
Rachel

Excelisfun
http://www.youtube.com/watch?v

outube.com/watch?v=IZLAzIYfMDU&list=PLA21AB17448044814

<-back

Find Last Filled Row/Column


13
a

13

#DIV/0!

{=MAX((A5:A20<>"")*ROW(A5:A20))}
array formula that will work for texts or numb
(A5:A20<>"")
this will return a bunch of TRUEs when cell is
{FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;FALSE
ROW(A5:A20))
the ROW formula will return the row number
{5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20
Excel regards TRUEs as 1 & FALSEs as 0, so if
{0;6;0;0;0;10;0;0;13;0;0;0;0;0;0;0}
MAX then takes the highest number of the lo

=LOOKUP("zzz",A5:A20,ROW(A5:A20))
this formula only works if you want to find th
it basically looks for a text that starts with "z
does when it cannot find an exact match is to
ignoring the blanks. It finds "c" in A13.
ROW(A5:A20)
the result vector using the ROW formula will
starting with "zzz", then repeat more Zs to be

=LOOKUP(2,1/(A5:A20<>""),ROW(A5:A20))
using the LOOKUP again, but works for both n
A5:A20<>""
this logical test of whether the range are blan
{FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;FALSE
1/(A5:A20<>"")
so again, since TRUEs are 1 & FALSEs are 0, 1
{#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;1;#DIV/
my lookup_value is "2", so since the LOOKUP
and using ROW(A5:A20) in the result_vector

ROW(A5:A20))}
ork for texts or numbers.

of TRUEs when cell is not empty & FALSEs when they are empty
SE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

urn the row number of the range stated.


14;15;16;17;18;19;20}
1 & FALSEs as 0, so if you multiply them together, you'll get
;0;0;0;0;0}
est number of the lot.

ROW(A5:A20))
f you want to find the last row where the text is. It won't work for numbers
xt that starts with "zzz". There will not be such a word, so what the LOOKUP
an exact match is to return the last value found in the lookup_vector (A5:A20),
nds "c" in A13.

he ROW formula will then return the row number of "c". If there are texts
repeat more Zs to be safe

>""),ROW(A5:A20))
, but works for both numbers & text

er the range are blanks will give TRUEs & FALSEs


SE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

e 1 & FALSEs are 0, 1 divided by these will give a bunch of 1s (1/1=1) & #DIV/0 (1/0=error)
V/0!;#DIV/0!;1;#DIV/0!;#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}
so since the LOOKUP cannot find an exact match, it returns the last number found
in the result_vector will give the row number of the last number found.

<-back

Word Count

This is to count words in Excel

Hard to imagine

Pretty cool stuf

Total number of words


13

To find out how many words there are, simply find out how many spaces there are & ad
spaces. Add 1 to it & you have the result of 3 words.

TRIM(A3:G12)
To play safe, TRIM the range A3:H20 to get rid of unnecessary spaces that exist (like a s
the end ,or more than 1 space in between).

LEN(TRIM(A3:G12))
this will find the length of characters between A3:H20.
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;31,0,0,0,17,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0

SUBSTITUTE(TRIM(A3:G12)," ","")
To find the number of spaces existing in the range, you can substitute spaces with blan
unnecessary spaces.

LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))
i then find the length of the characters between A3:H20 again, but this time without sp
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;25,0,0,0,15,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0

LEN(TRIM(A3:G12))-LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))+1
as I mentioned, we need to add 1 to the equation after getting the knowing how many
{1,1,1,1,1,1,1;1,1,1,1,1,1,1;7,1,1,1,3,1,1;1,1,1,1,1,1,1;1,1,1,1,1,1,1;1,1,1,1,1,1,1;1,1,1,

As you can see above, there's a slight problem. Cells that are empty now all have a va
(TRIM(A3:G12)<>"")
so we use another array of logical test here to find which cells are not blank
{FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,F

(LEN(TRIM(A3:G12))-LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))+1)*(TRIM(A3:G12)<>"")
As Excel treats TRUEs as 1s & FALSEs as 0s, our earlier results of the number of words a
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;7,0,0,0,3,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,

SUMPRODUCT((LEN(TRIM(A3:G12))-LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))+1)*(TRIM(A3
the SUMPRODUCT simply sums the numbers up & returns 13.

many spaces there are & add 1 to it. For eg. "I love Excel" has 2

ary spaces that exist (like a space before the start, space at

,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;15,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0}

n substitute spaces with blanks. Again, i use TRIM to get rid of

gain, but this time without spaces.


,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;13,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0}

ting the knowing how many spaces we have.


1,1,1,1,1;1,1,1,1,1,1,1;1,1,1,1,1,1,1;3,1,1,1,1,1,1;1,1,1,1,1,1,1;1,1,1,1,1,1,1}

are empty now all have a value of 1 because of the 1 I added.

ells are not blank


E,FALSE,FALSE,FALSE,FALSE,FALSE;TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FA

)+1)*(TRIM(A3:G12)<>"")
ults of the number of words are going to be multipled by 1s & 0s
0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;3,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0}

(A3:G12)," ",""))+1)*(TRIM(A3:G12)<>""))

FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FAL

FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;TRU

ALSE,FALSE,FALSE,FALSE;TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE

LSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}

<-back

Frequency (Count Unique Values)


Data

Category Counts
10
20
30
40
50
60
70
80
90
100

10
11
12
14
18
44
49
56
61
66
70
83
84
93
101

1
4
0
0
2
1
3
0
2
1
1

Definition
<=10
11 to 20
21 to 30
31 to 40
41 to 50
51 to 60
61 to 70
71 to 80
81 to 90
91 to 100
>100

Name
A
B
B
A
A
C
B
B
C
A
A
C
B
C
A

Data

Name
A
B

CountUniqueWithBlanks
#DIV/0!
dont need negation cos it's TRUEs/FALSEs divided

A
A

1
2
2
3
3
4
5
5
5
5
6
7
7
8
9

Duplicates CountUnique CountUniqueB


1
9
3
0
2
0
2
1
0
0
0
4
1
0
2
1
1

B
B
A
A
C
B
C
A

Name
A
B

CountUniqueWithBlanks&Wildcard
#N/A

1
*A
B
B
1
A
C
B
C
A
Name
Sioux
Sue
Chin
Swade
Martha
Luong
Sue
Sioux

Vote
Yes
No
Yes
Yes
Yes
No
No
Yes

Criteria
Yes

Other ways of obtaining no of unique items with condition


Code

Items

111 X
111 X
111 Y

Code

Unique Items

111

#N/A

222
222
222
333
333
333

X
Z
Z
X
Y
Z

http://www.youtube.com/watch?v=uUrI8hoj8BA&feature=plcp

<-back

Count Unique Values With Autofilter


Account Names
a
b
c
e
g
a
e

#N/A

We need to create set of 1s & 0s to


SUBTOTAL with function number 3
=SUBTOTAL(3,A5:A15)
it will count how many non-blank c
depending on whether the particul
SUBTOTAL(3,A5)
SUBTOTAL(3,A6)
...all the way to SUBTOTAL(3,A15),

to implement such a formula, i nee


inside the OFFSET, but we're just g

=OFFSET(reference,rows,cols,[hei
reference
this is the anchor point. so i placed

rows
this is how many rows you want it
to test it out, try inputting:
=OFFSET(A5,0,0)
it is equivalent to putting
=OFFSET(A5,,)
this means anchor in A5, & moving
=A5

since we want it to be looking at A


comes in now. the ROW formula gi
=ROW(A5)
so the above will return 5.

to put in a range, it will become an


=ROW(A5:A15)
you should see:
{5;6;7;8;9;10;11;12;13;14;15}
since we want to start from 0 to 10
=ROW(A5:A15)-ROW(A5)
{0;1;2;3;4;5;6;7;8;9;10}

=SUBTOTAL(3,OFFSET(A5,ROW(A5
so if you select the SUBTOTAL & O
{1;1;1;1;1;1;1;0;0;0;0}
this is when nothing is filtered. Th

it then combines with the FREQUE

reate set of 1s & 0s to make sure filtered & blank rows are not calculated. SUBTOTAL works great with filters. a
th function number 3 works like this:
(3,A5:A15)
how many non-blank cells exist in A5:A15. what i want is a series of numbers that will give me 1 count or 0 coun
n whether the particular cell is filtered or blank. that means i actually want

to SUBTOTAL(3,A15), but inside a single cell.

t such a formula, i need the range to be a dynamic one; using the OFFSET formula. there are 5 arguments you c
FSET, but we're just going to use 2 of them.

ference,rows,cols,[height],[width])

chor point. so i placed it in A5

any rows you want it away from the anchor point.


try inputting:

nt to putting

nchor in A5, & moving 0 rows & 0 columns away from A5. so this is exactly like putting:

nt it to be looking at A5, then A6, then A7, & so on... the "rows" is where we'll put numbers of 0 to 10. the ROW f
w. the ROW formula gives you the row number, regardless of what column it's in,
will return 5.

nge, it will become an array. to see the results select the formula & press F9

0;11;12;13;14;15}
nt to start from 0 to 10, you simply have to minus whatever row number you start in.
15)-ROW(A5)
6;7;8;9;10}

(3,OFFSET(A5,ROW(A5:A15)-ROW(A5),))
ct the SUBTOTAL & OFFSET formula above & press F9, you should be seeing:
1;0;0;0;0}
nothing is filtered. The last 4 zeroes are because the data are blanks.

nes with the FREQUENCY formula IF the above shows as 1 (non-filtered or non-blanks)

great with filters. a simple

me 1 count or 0 count,

e 5 arguments you can input

of 0 to 10. the ROW formula

<-back

SUMPRODUCT to work with Autofilter


Need to Filter
on range and get sumproduct total here
Price
Units
#VALUE!
Range 1
Range 1
Range 1
Range 1
Range 1
Range 1
Range 2
Range 2
Range 2
Range 2
Range 2
Range 2

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6

6.00
59.00
6.00
5.00
6.00
5.00
59.00
6.00
6.00
5.00
6.00
5.00

500
100
800
100
500
1,000
500
100
800
100
500
1,000

SUMPRODUCT(D8:D19,E8:E19)
a simple SUMPRODUCT like the ab
So that gives you 65,600.

hence, we need to create another


SUBTOTAL with function number 3
SUBTOTAL(3,B8:B19)
it will count how many non-blank
depending on whether the particu
SUBTOTAL(3,B8)
SUBTOTAL(3,B9)
...all the way to SUBTOTAL(3,B19)

to implement such a formula, i ne


inside the OFFSET, but we're just

=OFFSET(reference,rows,cols,[he
reference
this is the anchor point. so i place

rows
this is how many rows you want it
to test it out, try inputting:
=OFFSET(B8,0,0)
it is equivalent to putting
=OFFSET(B8,,)
this means anchor in B8, & movin
=B8

since we want it to be looking at B


comes in now. the ROW formula g
=ROW(B8)
so the above will return 8.

to put in a range, it will become a


=ROW(B8:B19)
you should see:
{8;9;10;11;12;13;14;15;16;17;18
since we want to start from 0 to 1
=ROW(B8:B19)-ROW(B8)
{0;1;2;3;4;5;6;7;8;9;10;11}

SUBTOTAL(3,OFFSET(B8,ROW(B8:
so if you select the SUBTOTAL & O
{1;1;1;1;1;1;1;1;1;1;1;1}
this is when nothing is filtered. af

what SUMPRODUCT does is to mu


so you notice that whatever is filt

T(D8:D19,E8:E19)
MPRODUCT like the above would simply give you a result of D8*E8 + D9*E9 + .. And so on
you 65,600.

eed to create another set of 1s & 0s to make sure filtered rows are not calculated. SUBTOTAL works great with fil
th function number 3 works like this:

how many non-blank cells exist in B8:B19. what i want is a series of numbers that will give me 1 count or 0 coun
n whether the particular cell is filtered. that means i actually want

to SUBTOTAL(3,B19), but inside a single cell.

t such a formula, i need the range to be a dynamic one; using the OFFSET formula. there are 5 arguments you c
FSET, but we're just going to use 2 of them.

ference,rows,cols,[height],[width])

chor point. so i placed it in B8

any rows you want it away from the anchor point.


try inputting:

nt to putting

nchor in B8, & moving 0 rows & 0 columns away from B8. so this is exactly like putting:

nt it to be looking at B8, then B9, then B10, & so on... the "rows" is where we'll put numbers of 0 to 11. the ROW
w. the ROW formula gives you the row number, regardless of what column it's in,
will return 8.

nge, it will become an array. to see the results select the formula & press F9

2;13;14;15;16;17;18;19}
nt to start from 0 to 11, you simply have to minus whatever row number you start in.
19)-ROW(B8)
6;7;8;9;10;11}

OFFSET(B8,ROW(B8:B19)-ROW(B8),))
ct the SUBTOTAL & OFFSET formula above & press F9, you should be seeing:
1;1;1;1;1;1}
nothing is filtered. after filtering, you should see a couple of 0s appearing.

ODUCT does is to multiply & add these numbers, so this is how it does it:
e that whatever is filtered wont be calculated because anything multiplies by 0 is 0.

L works great with filters. a simple

me 1 count or 0 count,

e 5 arguments you can input

s of 0 to 11. the ROW formula

<-back

Count Unique Date for Supplier (Non-array)


Date

31-Jul-12
1-Aug-12
3-Aug-12
6-Aug-12
8-Aug-12
9-Aug-12
14-Aug-12
15-Aug-12
17-Aug-12
17-Aug-12
17-Aug-12
20-Aug-12
24-Aug-12
27-Aug-12
27-Aug-12
29-Aug-12
31-Aug-12
31-Aug-12
3-Sep-12
4-Sep-12

Supplier

A
A
A
A
A
A
A
B
B
C
B
B
B
A
B
B
B
C
C
C

Mine

Supplier

Date

Aug_2012

by Ron Coderre
0

2 logical tests need to done before counting the unique values.


=(TEXT(A4:A23,"mmm\_yyyy")=G4)
this will convert A4:A23 into "mmm\_yyyy" format like the value in G4 for an
the results would be:
{FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TR

the 2nd logical test is:


=(B4:B23=F4)
just to check if B4:B23 is Supplier "A" found in F4. it'll return:
{TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;

the next step is to combine the range of column A & B to make the values un
and we only want to take in the 1st value that appear as the unique value. F
twice; once in row 12 & the other in row 14. we only want to take in row 12
to find the row number the first time the unique value appeared, we can use
=MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)
dates are actually serial numbers (if you didnt know that. But that's a whole
to General & you'll see what I mean). So if you combine A4&B4, you actually
number of 31-Jul-12 & combining with "A". So the MATCH formula finds "411
& returns 1 (1st value). it then searches for A5&B5 in the same range & retu
returns such an array:
{1;2;3;4;5;6;7;8;9;10;9;12;13;14;15;16;17;18;19;20}
notice that the 11th value (which is referring to A14 since we start from A4)
MATCH returns the 1st instance of the row it finds. The combination 17-Aug-

we then need to convert the above into TRUEs & FALSEs. TRUE is whenever
whenever it repeats. For this case, only the red value above should be FALS
above to an incremental number of 1 to 20. when it reaches the 11th value,
it'll turn FALSE.
=(ROW(B4:B23)-ROW(B4)+1)
{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20}

so combining the 2 together to make it a logical test would be:


=MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)
{TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TR

now that we have the 3 logical tests, simply multiply them to get the final ou
=(TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A
{FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE
Only when 3 logical tests turns TRUE will it be TRUE because TRUE is equiva
by 0 is 0.

If I were to then use 1 to divide it by a bunch of TRUEs & FALSEs, it will give
is 1 while 1/FALSE(or 0) is a DIV error
=1/((TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B2
{#DIV/0!;1;1;1;1;1;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;1;#

the COUNT formula will count how many of them are numbers, ignoring erro
formula inside a COUNT formula, it would have to be an array formula. To pr
formula inside an INDEX formula. By putting in a "0" for the row argument o
the array of values instead of a single value an INDEX formula usually return
=INDEX(1/((TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23

The final part is simply to add the COUNT formula:


=COUNT(INDEX(1/((TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH

e unique values.

mat like the value in G4 for an apple-to-apple comparison

UE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE}

F4. it'll return:


SE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

n A & B to make the values unique to the Date & Supplier


appear as the unique value. For eg in 17-Aug-12, Supplier "B" appeared
e only want to take in row 12 in order not to double-count
e value appeared, we can use:

know that. But that's a whole long story. Format cells of column A
combine A4&B4, you actually get "41121A"; "41121" being the serial
the MATCH formula finds "41121A" inside the range of A4:A23&B4:B23
&B5 in the same range & returns 2 (2nd value). it continues &

A14 since we start from A4) is 9 instead of 11. That is because


ds. The combination 17-Aug-12 & "B" is already found in the 9th value

& FALSEs. TRUE is whenever the value is the 1st instance, FALSE is
d value above should be FALSE. To do that, simply compare the
hen it reaches the 11th value, it will use the 9 in red above vs 11 &

l test would be:


(ROW(B4:B23)-ROW(B4)+1)
E;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}

ultiply them to get the final outcome of TRUEs & FALSEs.:


F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)
SE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}
TRUE because TRUE is equivalent to 1 & FALSE to 0. Anything multiplied

TRUEs & FALSEs, it will give me 1s & DIV errors because 1/TRUE(or 1)

3=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1))
#DIV/0!;#DIV/0!;#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}

m are numbers, ignoring errors. But if you simply put the above
to be an array formula. To prevent that, put the whole chunk of
a "0" for the row argument of the INDEX formula, it will give you
INDEX formula usually returns.
*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)),0)

y")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)),0))

<-back

Flip the 1st & last Name & in proper casing


JONES/JACK

Jack Jones

The SUBSTITUTE & REPT method is extremely u


rough idea. And I also found the flipping of the
=A4&" "&A4
what the formula does is to use A4, combine it
the middle.
JONES/JACK JONES/JACK

there are 3 parts in the above text, separated b


A good number to use would be double the leng

=SUBSTITUTE(A4&" "&A4,"/",REPT(" ",100))


so to do the substitution, "JONES/JACK JONES/JA
repeat a certain text the number of times you d
"JONES

=MID(SUBSTITUTE(A4&" "&A4,"/",REPT(" ",100


the text with 100 spaces in between will be in o
you want the 1st part, then put in "1". For the
you repeated spaces, multiplied by 2. this will
texts.
"
JACK JONES

To remove the unnecessary spaces, simply use


between words. Lastly, user PROPER to make s
=PROPER(TRIM(MID(SUBSTITUTE(A4&" "&A4,"/

method is extremely useful in doing a Text-To-Column style using just a formula to copy across. This eg doesn
ound the flipping of the Name interesting.

s to use A4, combine it with a space & with cell A4 again. It creates the below efect & what we have to do is ex

above text, separated by the backslash. To make it easy for us to extract, we can substitute the slashes by a hu
ould be double the length of the text in A4. 100 is just a bigger & safer number to use.

A4,"/",REPT(" ",100))
, "JONES/JACK JONES/JACK" will be the text where it will substitute the 2 "/" with 100 spaces (using the REPT form
number of times you desire. That will give you this result:
JACK JONES

" "&A4,"/",REPT(" ",100)),100,100)


in between will be in our 1st argument of the MID formula. The 2nd argument depends on which part of the te
hen put in "1". For the 2nd part, put in the number of times you repeated the spaces. For the 3rd part, put in th
ultiplied by 2. this will ensure you have selected a bunch of spaces, along with the text you want, without includ
"

ary spaces, simply use TRIM. TRIM will remove spaces before & after the first & last words, and ensure only a si
user PROPER to make sure the first letter is in Capital letter & the rest in small.
BSTITUTE(A4&" "&A4,"/",REPT(" ",100)),100,100)))

ross. This eg doesnt do that but gives a

t we have to do is extract everything in

e the slashes by a hundred spaces in between.

(using the REPT formula). REPT is to


JACK"

n which part of the text do you want. If


he 3rd part, put in the number of times
u want, without including the unwanted

and ensure only a single space is in

<-back

Find if Exact Match exist in string of texts


Find "M1"
M10,M1,M120
M10,M120

1
0

if you simply search for "M1" within the text, you'l


in a scenario where "M1" is the 1st text to appear,
But we can't do that because if it appears in the la
so if we want to find an exact match, add in comm
=","&A5&","
that will give us:
,M10,M1,M120,

so we can now search for ",M1," & no matter whic


=SEARCH(",M1,",","&A5&",")

lastly, put in ISNUMBER to return whether or not th


=ISNUMBER(SEARCH(",M1,",","&A5&",")

"M1" within the text, you'll notice that anything containing "M1" would be considered. Anything like M10, M120
" is the 1st text to appear, it would be "M1,etc, etc". So a safer bet would be to find "M1," instead of just "M1".
ause if it appears in the last text, it would not contain a comma behind. Eg. "etc, etc, M1"
exact match, add in commas in front & behind the text

r ",M1," & no matter which position it's in, it will have commas both in front & behind.

to return whether or not the SEARCH formula contains a number. If it does, it means ",M1," is found
M1,",","&A5&","))

thing like M10, M120 or EM10.


nstead of just "M1".

<-back

Position of the last occurance of certain character


Find last "."
lalala.woooo.com
ahh.oooh.e.yy

13
11

this is especially useful when you need to extract everyth

=LEN(A5)
first, you can find out how many of such a character are t
you will get 16 characters

=LEN(SUBSTITUTE(A5,".",""))
then substitute the character (the one we are showing he
you will get 14 characters. That means if the text is witho

=LEN(A5)-LEN(SUBSTITUTE(A5,".",""))
take the diference of both & you'll get how many of such
the results is 2.

=SUBSTITUTE(A5,".","*",LEN(A5)-LEN(SUBSTITUTE(A5,"."
the last argument of the SUBSTITUTE formula actually allo
character that don't normally occur. Let's use "*". And in
this will be the result:
lalala.woooo*com

=FIND("*",SUBSTITUTE(A5,".","*",LEN(A5)-LEN(SUBSTITU
with a special character "*" now, it's much easier to find t

eed to extract everything before or after the last occurance of a certain character.

such a character are there. To do that, find the length of the text

ne we are showing here is ".") with blanks & find out the length
ans if the text is without the ".", you have 14 characters

get how many of such characters (".") are there

EN(SUBSTITUTE(A5,".","")))
E formula actually allows you to only substitute that particular instance. We can substitute the last instance of
Let's use "*". And in the last argument, it's the result we obtained above to find the last instance of "."

EN(A5)-LEN(SUBSTITUTE(A5,".",""))))
s much easier to find the position

e the last instance of "." with some special


nstance of "."

<-back

COUNTIF to count non-blanks or blanks


Count non-blank text entries
2a
2
3c

Count blank
0a
0
1c

Using COUNTIF(B5:B7,"<>") or COUNTA will not conside


so you can use COUNTIF(B5:B7,">""") for this case. Do

just an alternative to COUNTBLANK, COUNTIF with "=" d

UNTA will not consider "" returned by a formula to be blank


"") for this case. Do note that this only works on text.

COUNTIF with "=" does the same, or just ""

<-back

Return array of results using INDEX

1
2
3
4
5
6
7
8

grade 1
A
C
B
C
B
B
F
F

grade 2
A
A
A
A
A
B
B
C

grade 3
C
C
D
D
F
B
A
C

grade 4
B
B
C
C
D
F
F
A

A
7
1
2
6
5
3
8
4

1
2
1
0
1
1
1
1

to zoom into the corre

=MATCH($G5,$A$5:$
this will give you the r

=INDEX($B$5:$E$12,
and instead of returnin
if you were to select th
{"F","B","A","F"}
that's what B11:E11 c
=INDEX($B$5:$E$12,

C
1
1
1
3
1
1
0
0

D
0
1
2
0
0
1
2
2

F
0
0
0
0
1
1
0
1

2
0
0
1
1
0
1
0

o zoom into the correct row for COUNTIF, you can use INDEX with "0" in the column_num to return an array of re

=MATCH($G5,$A$5:$A$12,0)
his will give you the row position G5 (7) is found in A5:A12

=INDEX($B$5:$E$12,MATCH($G5,$A$5:$A$12,0),0)
nd instead of returning a single value from that row position, we can use "0" in the end to return the results from
you were to select the above above & press F9 to calculate, you'll get:
"F","B","A","F"}
hat's what B11:E11 contains. You can also omit zero and the default value is 0
=INDEX($B$5:$E$12,MATCH($G5,$A$5:$A$12,0),)

return an array of results

eturn the results from B11:E11

<-back

Find last value/text


814
#N/A
#DIV/0!

814 Value
#N/A Text

320
478
c
880
64

Both
a

814

The LOOKUP & VLOOKUP


of the values searched,
type 9E+10 to get 9 + 1

he LOOKUP & VLOOKUP with approximate match will first look for an exact match. In a scenario where lookup v
f the values searched, it will return the last value
ype 9E+10 to get 9 + 10 zeros

nario where lookup value is larger than all

<-back

Round Up Time to next 5 mins

10:02 AM
8:36 AM
4:29 PM

by daddylonglegs
10:05 AM
8:40 AM
4:30 PM

<-back

Rank tie the same and the next + 1


Students Ranking
Name
Scores
Ranking
15
Lola
21%
16
Manny
18%
17
Frances
15%
19
Cindy
10%
1
Tamie
97%
14
Ben
32%
5
Smith
86%
4
Willy
88%
10
James
50%
18
Penny
11%
13
Lance
34%
3
Adam
90%
12
Emerson
43%
7
Rose
69%
7
Kathy
69%
1
Jerry
97%
8
Wally
59%
6
Donna
78%
18
Colleen
11%
11
Nelly
45%
2
Tom
92%
9
Sam
55%

Alternative
15
16
17
19
1
14
5
4
10
18
13
3
12
7
7
1
8
6
18
11
2
9

To prevent using an array formula in column C, you can use the SUMPRODUCT method in column F

=(B6<=$B$6:$B$27)
The aim here is to count how cells are greater or equals to B6. that will be the Score ranking.
A list of TRUEs & FALSEs will be returned:
{TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TR
But do note that due to same Scores by 2 or more people, the ranking is skewed.

=COUNTIF($B$6:$B$27,$B$6:$B$27)
to find out if the Scores are duplicates, we can use COUNTIF & the range is the same as the criteria.
{1;1;1;1;2;1;1;1;1;2;1;1;1;2;2;2;1;1;2;1;1;1}
this results means 21% appeared once, 18%, once, 15% once. When it reaches 97% (B10), it actually

=1/COUNTIF($B$6:$B$27,$B$6:$B$27)
this next part is then to use 1 divided by those numbers above. If the Score appeared only once, it'll b
twice, it would be 1/2 & return 0.5
{1;1;1;1;0.5;1;1;1;1;0.5;1;1;1;0.5;0.5;0.5;1;1;0.5;1;1;1}
and of course, if there were Scores that appeared thrice, it will take 1/3

=($B$6:$B$27>=B6)*1/COUNTIF($B$6:$B$27,$B$6:$B$27)
and if we multiply both of the 2 above, those duplicates will have values less than 1.
{1;0;0;0;0.5;1;1;1;1;0;1;1;1;0.5;0.5;0.5;1;1;0;1;1;1}
but the end result after adding them up the duplicates would always be 1, thus ensuring we do not do
=SUMPRODUCT(($B$6:$B$27>=B6)*1/COUNTIF($B$6:$B$27,$B$6:$B$27))
the SUMPRODUCT helps us do the summing.

ethod in column F

ore ranking.

;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE}

ame as the criteria.

97% (B10), it actually appears twice, the other one in B21

eared only once, it'll be 1/1 & return 1. but if it appears

nsuring we do not double count

<-back

SUMPRODUCT with Criteria in 2 Columns


Calculate Column D if Colum A or B "Jill", Col C "Floor" or "Counter"
Jill
Jay
Floor
1.3
5.65
Jane
Jill
Counter
1.3
Jay
Jane
Floor
1.05
Jill
Joe
Counter
1.7
Jay
Jill
Floor
1.35
Jane
Jay
Counter
1.3
Jill
Joe
Stop
2.1

Use "+" for either column to have "Jill", curly brackets for a column to have "Floor" or "Counter"

or" or "Counter"

<-back

Put the "st,nd,rd,th" behind the day


1-Nov-12
2-Nov-12
3-Nov-12
4-Nov-12
5-Nov-12
6-Nov-12
7-Nov-12
8-Nov-12
9-Nov-12
10-Nov-12
11-Nov-12
12-Nov-12
13-Nov-12
14-Nov-12
15-Nov-12
16-Nov-12
17-Nov-12
18-Nov-12
19-Nov-12
20-Nov-12

1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
12th
13th
14th
15th
16th
17th
18th
19th
20th

=DAY(A4)
The day formula returns the day of the d

The LOOKUP formula searches for an ex


We could make a lookup_vector of 1 to 3
But there are some numbers in between
So these are the only numbers we need
{1,2,3,4,21,22,23,24,31}
and the respective texts it returns:
{"st","nd","rd","th","st","nd","rd","th","s

so when the day is say 8, it is unable to


will then return the text "th".

Combined with the ampersand key, it co

mula returns the day of the date

formula searches for an exact match of the lookup_value in the lookup_vector first. If it can't find one, it retu
ke a lookup_vector of 1 to 31 & the results vector with the text of "st" for 1st, "nd" for 2nd, "rd" for 3rd & so o
some numbers in between we can actually skip; from 4th to 20th are all ending with "th". The same for 24t
the only numbers we need:
22,23,24,31}
ective texts it returns:
d","th","st","nd","rd","th","st"}

day is say 8, it is unable to find an exact match in the lookup_vector. It then goes back to the last value clos
rn the text "th".

th the ampersand key, it combines the day of the date & the text

rst. If it can't find one, it returns the last value closest to it


d" for 2nd, "rd" for 3rd & so on
g with "th". The same for 24th to 30th.

es back to the last value closest to it & picks "4". The result_vector

<-back

Sum 1st 12 non-blank cells


653
438
254

1
0
78

10

23
55

56

44
54

55
33

66
25

=ISNUMBER(C4:U4)
To find out if C4:U4 contains numbers, we can use ISNUMBER. That will give us a bu
{TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALS

=IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1)
When they are indeed numbers, then return the column number they are in. COLUM
{3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}
but what we want is to start from 1. So we deduct the column it starts from using CO
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}
we then add +1 to it to make it start from 1:
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
so only when the cells are numbers using ISNUMBER, the column numbers will show
{1,FALSE,3,FALSE,5,6,7,8,9,FALSE,11,12,13,FALSE,15,16,FALSE,18,FALSE}

=SMALL(IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1),MIN(12,COUNT(C4:
We need to know the 12th smallest column number to decide where our SUM should
But in a scenario where there could be a possibility of less than 12 numbers availabl
count of numbers, depending which is smaller. So in our case here, we have 13 num
number is 16, where the last 44 resides.

=INDEX(C4:U4,SMALL(IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1),MIN(1
If we put all of that inside the INDEX formula, we would get the value 44, which is in

=C4:INDEX(C4:U4,SMALL(IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1),MI
But here's a cool trick. If you put a cell reference in front of it with a colon & then slo
=C4:R4
R4 was obtained by using the INDEX formula

=SUM(C4:INDEX(C4:U4,SMALL(IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+
Lastly, just put a SUM to sum up C4:R4. press CTRL + SHIFT + ENTER to confirm as

77
47

88
26

24
5

86

67

78
99

44
28

. That will give us a bunch of TRUEs & FALSEs


E,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE}

ber they are in. COLUMN(C4:U4) would have given us:

n it starts from using COLUMN(C4) to return:

umn numbers will show up as:


E,18,FALSE}

+1),MIN(12,COUNT(C4:U4)))
e where our SUM should stop. Hence, we can use the SMALL formula where the above formula gives us the arra
an 12 numbers available, we can use COUNT to count how many numbers there are. We then take the MIN of b
e here, we have 13 numbers in C4:U4. We would take 12 since 12 is smaller than 13. Therefore, the 12th small

-COLUMN(C4)+1),MIN(12,COUNT(C4:U4))))
he value 44, which is in cell R4.

U4)-COLUMN(C4)+1),MIN(12,COUNT(C4:U4))))
with a colon & then slot in the INDEX formula, it will give you a cell range. It's equivalent to putting:

N(C4:U4)-COLUMN(C4)+1),MIN(12,COUNT(C4:U4)))))
+ ENTER to confirm as this is an array formula

10
55
55

28

93
93

ula gives us the array of values


en take the MIN of both values; 12 or the
efore, the 12th smallest value of the column

o putting:

<-back

Sum unique -ve & non-NA


-100
-100
-100
#N/A
#N/A
#N/A
120
120
120
120
-190
-190
200
200

-290

We need to do 3 things here; identify which are numb

=ISNUMBER(A4:A17)
this will let us know which are numbers. Those with n
{TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;TR

=A4:A17<0
All those that are lesser than 0 would turn TRUE, othe
{TRUE;TRUE;TRUE;#N/A;#N/A;#N/A;FALSE;FALSE;FAL

=IF(ISNUMBER(A4:A17),IF(A4:A17<0,
once we put the logical tests this way, it eliminates th
it then does this:
A4:A17/COUNTIF(A4:A17,A4:A17)
The COUNTIF will count how many times each row ap
{3;3;3;3;3;3;4;4;4;4;2;2;2;2}
the above means the value of A4 appeared 3 times.
by the number of times each row appears, summing
{-33.3333333333333;-33.3333333333333;-33.33333
the value "-100" in A4 appeared 3 times, so it took -1
twice. Hence, -190/2 & returns "-95".

=SUM(IF(ISNUMBER(A4:A17),IF(A4:A17<0,A4:A17/CO
By summing up the numbers above, it will return wha

here; identify which are numbers (non-errors), which are negative values & add them up just once if it repeat

ch are numbers. Those with numbers will be TRUE & those with errors will flag out as FALSE
E;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}

than 0 would turn TRUE, otherwise FALSE. Note that this logical test must be after the ISNUMBER. Otherwis
;#N/A;#N/A;FALSE;FALSE;FALSE;FALSE;TRUE;TRUE;FALSE;FALSE}

,IF(A4:A17<0,A4:A17/COUNTIF(A4:A17,A4:A17)))
ests this way, it eliminates the N/As in the first logical test first before proceeding to whether A4:A17 is lesse

how many times each row appears.

lue of A4 appeared 3 times. So did A5:A9. Value in A10 appeared 4 times, & so on. So if we were to take th
each row appears, summing them up will ensure we dont double count. So if you select everything inside th
3.3333333333333;-33.3333333333333;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;-95;-95;FALSE;FALSE}
ppeared 3 times, so it took -100/3 & returns "-33.3333.". The 4th value is FALSE because it's N/A. The othe
returns "-95".

A17),IF(A4:A17<0,A4:A17/COUNTIF(A4:A17,A4:A17))))
bers above, it will return what we need.

them up just once if it repeats.

out as FALSE

ter the ISNUMBER. Otherwise, N/As will appear.

ng to whether A4:A17 is lesser than 0. when both are TRUE,

on. So if we were to take the values in A4:A17 & divide it


ou select everything inside the SUM & press F9:
FALSE;-95;-95;FALSE;FALSE}
SE because it's N/A. The other value is "-190", which appeared

<-back

Convert yyyymmddhhmm to proper format

Date
201206010053

by daddylonglegs
1-Jun-12 00:53

custom
custom
with "A"0 with \A0
A10
A10

Backslash will treat the next single text as if in double quotes

<-back

Non-array Way of Min with Condition


Name
a
v
a
g
a

Cost
89
26
73
33
66

Name
a

Array
66
1

Mine
Err:504
3

Marcelo Branco
66
4

My Method
=(A5:A9="a")
I used a logical test to find out if A5:A9 is
{TRUE;FALSE;TRUE;FALSE;TRUE}

=(A5:A9="a")*(B5:B9)
Excel treats TRUEs as 1 & FALSEs as 0. so
{89;0;73;0;66}

=INDEX((A5:A9="a")*(B5:B9),)
to make it a non-array formula, I store it in
=INDEX((A5:A9="a")*(B5:B9),0
And this will return you a series of values

=COUNTIF(A5:A9,"<>a")+1
however, if I were to look for the minimum
not have "a" in A5:A9. What I want here i
how many cells are NOT equals to "a" in A

=SMALL(INDEX((A5:A9="a")*(B5:B9),),CO
With that, I can use the SMALL formula to

Marcelo Branco's method


=(A5:A9=D5)*B5:B9
Using the same logical test, we can find o
{89;0;73;0;66}

=9.99E+307*(A5:A9<>D5)
9.99E+307 is the largest number Excel ca
{0;9.99E+307;0;9.99E+307;0}

=(A5:A9=D5)*B5:B9+ 9.99E+307*(A5:A9
By adding the 2 up, every cells that has "a
{89;9.99E+307;73;9.99E+307;66}

=MIN((A5:A9=D5)*B5:B9+ 9.99E+307*(A
With that, you can then find the minimum

=SUMPRODUCT(MIN((A5:A9=D5)*B5:B9+
the number though, is obtained through a

T. Valko's method
=1E+100*(A5:A9<>D5)
1E+100 is 1 plus a hundred zeroes. Like M
to multiply only when A5:A9 is NOT equal
{0;1E+100;0;1E+100;0}
=1E+100*(A5:A9<>D5)+B5:B9
we then add the original values of B5:B9
{89;1E+100;73;1E+100;66}

=SUMPRODUCT(MIN(1E+100*(A5:A9<>D
The SUMPRODUCT & the MIN has the sam

Explanation added: Dec 2013


Jeeped's method
http://answers.microsoft.com/en-us/office/

daddylongleg's method
=LARGE(INDEX((A4:A13=E4)*B4:B13,0),C
You might think that the MIN & IF would b
It cannot work because the results for the
zero if any values in A4:A13 is not "abc".
You can still do the same logical test mult
=(A4:A13=E4)*B4:B13
to store these values so that they won't b
=INDEX((A4:A13=E4)*B4:B13,0)
I have 4 values in A4:A13 that are "abc".
array obtained fromINDEX((A4:A13=E4)*B4:B
{0;0;0;740;0;470;120;0;0;170}
To find out how many times "abc" appeare
=COUNTIF(A4:A13,E4)
To end it, use the LARGE formula to find th

T. Valko
66
1

Added: Dec 2013


Jeeped
daddylonglegs
Err:504
Err:504
2
3
Speed, using Charles Kyd's Calculation Timer - Fastest to

o find out if A5:A9 is equals to "a". It will return a bunch of TRUEs & FALSEs
ALSE;TRUE}

1 & FALSEs as 0. so if I were to multiply them by the values in B5:B9, I would get the values just for those w

*(B5:B9),)
y formula, I store it inside an INDEX formula. By not putting any values in the row_num portion, it is equivale
*(B5:B9),0)
ou a series of values instead of just a single value

ook for the minimum value in {89;0;73;0;66}, it would return me 0. that's not what I want. 0 appeared bec
. What I want here is actually the 3rd smallest number, since there are 2 zeroes. 66 is what I want to return
OT equals to "a" in A5:A9. those will be the count of A6 & A8, equivalent to the count of zeroes. Then I add

A9="a")*(B5:B9),),COUNTIF(A5:A9,"<>a")+1)
he SMALL formula to find out the 3rd smallest of the array.

al test, we can find out which cells in A5:A9 is equals to "a". And again, it's multiplied by the values in B5:B9

gest number Excel can store. This is multiplied by a diferent logical test; when A5:A9 is NOT equals to "a".
E+307;0}

+ 9.99E+307*(A5:A9<>D5)
very cells that has "a" in A5:A9 will be its original value. Every other cells will be having the biggest number
99E+307;66}

5:B9+ 9.99E+307*(A5:A9<>D5))
en find the minimum of all the values & get "66"

((A5:A9=D5)*B5:B9+ 9.99E+307*(A5:A9<>D5)))
s obtained through an array & needs to be within the SUMPRODUCT to make it non-array

undred zeroes. Like Marcelo Branco's method, this is also using a huge number multiplied by the same 2nd l
A5:A9 is NOT equals to "a"

D5)+B5:B9
nal values of B5:B9

(1E+100*(A5:A9<>D5)+B5:B9))
the MIN has the same efect as Marcelo's

: Dec 2013

oft.com/en-us/office/wiki/office_2013_release-excel/minif-maxif-and-modeif-with-standard-formulas/144a2f30

A13=E4)*B4:B13,0),COUNTIF(A4:A13,E4))
he MIN & IF would be simply to change the MAX to MIN in the SUMPRODUCT formula earlier.
se the results for the FALSEs would give you a bunch of zeroes and the MIN would definitely return
A4:A13 is not "abc".
ame logical test multiplied by the values in B4:B13 like this:

so that they won't become an array is to use INDEX with 0 as the row_num:
)*B4:B13,0)
A13 that are "abc". Hence, the smallest number for "abc" is actually the 4th largest number in my

NDEX((A4:A13=E4)*B4:B13,0)

0;0;0;170}
times "abc" appeared, I can use COUNTIF:

RGE formula to find the nth largest number.

ion Timer - Fastest to Slowest (1-5)

alues just for those whose Names in A5:A9 are "a"

portion, it is equivalent to putting a 0:

want. 0 appeared because those values did


what I want to return. So I can use COUNTIF to count
of zeroes. Then I add +1 to say I want the 3rd smallest

y the values in B5:B9

s NOT equals to "a".

g the biggest number Excel can hold. So:

ed by the same 2nd logical test Marcelo did;

rd-formulas/144a2f30-31ef-408e-86c3-f1443d9ac1fd

itely return

mber in my

<-back

Non-array Way of Max with Condition


tigeravatar
xyz
xyz
xyz
abc
xyz
abc
abc
xyz
xyz
abc

50
270
280
740
1000
470
120
410
250
170

abc

740
MAX with IF
740

Explanation added: Jul 2013


The formula is basically to avoid keying in an array formula like I did in F7

=SUMPRODUCT(MAX((A4:A13=E4)*B4:B13))
This formula to substitute the MAX & IF is much simpler. You can first find out if A4:A13
=A4:A13=E4
That will return TRUEs & FALSEs:
{FALSE;FALSE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE;FALSE;TRUE}
to return the numbers when the above logical test is TRUE, try:
=(A4:A13=E4)*B4:B13
The results will show B4:B13 numbers if A4:A13 is "abc" & 0 if they are not
{0;0;0;740;0;470;120;0;0;170}
By putting a MAX formula, you can then find out which is the maximum.
=MAX((A4:A13=E4)*B4:B13)
But the above is an array of values & you would need to press CTRL + SHIFT + ENTER t
can add in the SUMPRODUCT & that settles it.

=LARGE(INDEX((A4:A13=E4)*B4:B13,0),COUNTIF(A4:A13,E4))
You might think that the MIN & IF would be simply to change the MAX to MIN in the SUM
It cannot work because the results for the FALSEs would give you a bunch of zeroes and
zero if any values in A4:A13 is not "abc".
You can still do the same logical test multiplied by the values in B4:B13 like this:
=(A4:A13=E4)*B4:B13
to store these values so that they won't become an array is to use INDEX with 0 as the
=INDEX((A4:A13=E4)*B4:B13,0)
I have 4 values in A4:A13 that are "abc". Hence, the smallest number for "abc" is actua
array obtained fromINDEX((A4:A13=E4)*B4:B13,0)
{0;0;0;740;0;470;120;0;0;170}
To find out how many times "abc" appeared, I can use COUNTIF:
=COUNTIF(A4:A13,E4)
To end it, use the LARGE formula to find the nth largest number.

a like I did in F7

ou can first find out if A4:A13 is "abc" by doing:

0 if they are not

he maximum.

ress CTRL + SHIFT + ENTER to confirm it. To prevent that, you

ge the MAX to MIN in the SUMPRODUCT formula earlier.


ve you a bunch of zeroes and the MIN would definitely return

ues in B4:B13 like this:

s to use INDEX with 0 as the row_num:

est number for "abc" is actually the 4th largest number in my

<-back

Arrange in 1 column, by row then by column


Top Rated

2nd Rated

White Coppice

Becky Lou

Summer Dream

Zero Game

Face The Problem

Rowe Park

Communicator

Area Fifty One

White Coppice
Becky Lou
Summer Dream
Zero Game
Face The Problem
Rowe Park
Communicator
Area Fifty One

The pattern here is tha


If you noticed, the row

=(ROWS(D$5:D5)+1)/
ROWS formula will cou
row, it's going to increa
would be (2+1)/2 & ret
2. following that would

=MOD(ROWS(D$5:D5
The MOD formula retur
=MOD(3,2)
3 can be divided by 2 &
=MOD(4,2)
4 can be wholly divide
We are going to use RO
0. We then add +1 be
add +1 for it to becom
=INDEX(A$5:B$9,
And then, we can add
column_num.

he pattern here is that we must first pick up the 1st row, 1st column. Then followed by 1st row, 2nd column. An
you noticed, the rows is to increase by 1 after every 2 rows & the column is to switch between 1 & 2.

=(ROWS(D$5:D5)+1)/2
OWS formula will count how rows are there in the range stated. I stated D$5:D5, so there is only 1 row in total.
ow, it's going to increase by 1 when the formula is copied down. I then added 1 because I want the first cell to b
ould be (2+1)/2 & return me 1.5. INDEX will only take the integer & hence take only 1, ignoring 0.5. the 3rd ro
. following that would be (4+1)/2, returning 2.5. Notice that I'm now getting an increment of 1 after 2 rows.

=MOD(ROWS(D$5:D5)-1,2)+1
he MOD formula returns the remainder that cannot be divisible by the divisor stated. An eg:
=MOD(3,2)
can be divided by 2 & a remaining of 1 cannot be divisible to return a whole number. Hence, it returns 1 as the
=MOD(4,2)
can be wholly divided by 2 & hence return 0 as the remainder.
We are going to use ROWS again & lock the row to get 1 for the first cell. We then minus 1 to obtain 0. so it beco
. We then add +1 behind to obtain 1. The reason for deducting & adding is for the next row. It becomes MOD(2
dd +1 for it to become 2.

=INDEX(A$5:B$9,(ROWS(D$5:D5)+1)/2,MOD(ROWS(D$5:D5)-1,2)+1)
nd then, we can add in the INDEX formula & choose A5:B9 as the array, while the other 2 formula combinations
olumn_num.

row, 2nd column. And then 2, 1. 2, 2. 3, 1. 3, 2.


een 1 & 2.

s only 1 row in total. But because I locked the


want the first cell to be 2/2 to get 1. The 2nd row
oring 0.5. the 3rd row would be (3+1)/2 & returns
of 1 after 2 rows.

ce, it returns 1 as the remainder. if I were to put:

o obtain 0. so it becomes MOD(1-1,2) & return


w. It becomes MOD(2-1,2) & returns 1. We then

ormula combinations give us the row_num &

<-back

List non-blank fields without array


0 Solution by Marcol

Peter
Paul
Tracy

John

John

Darcy

Abigail
Darcy

James

0
0
0

As you can see here in A4:A13, there are


C4:C13

Those of us who knows array formulas can


especially if youre dealing with a huge fil

James

First of, we can see that what we need is


So lets do a formula that returns the row
=ROW(A4)

It will return me the row number of A4, wh


=ROW($A$4:$A$13)
{4;5;6;7;8;9;10;11;12;13}
As you can see, it creates a list of number
=ROW($A$4:$A$13)

Since row 7, 9 & 12 are blanks, we have t


out if the cells are blanks:
=$A$4:$A$13<>""

Again, if you click inside the formula bar &


FALSE means it is a blank:
{TRUE;TRUE;TRUE;FALSE;TRUE;FALSE;TRU
Now, TRUE in Excel is actually equivalent
to get the 0 for the blank cells.
=($A$4:$A$13<>"")*ROW($A$4:$A$13)
{4;5;6;0;8;0;10;11;0;13}

So this is what actually happened. A4 for


course 4, so the multiplication will be 1
value of it is 0. Whatever the row numb
Cell
A4
A5
A6
A7
A8
A9
A10

A11
A12
A13

If we were to rank the numbers after the m


value on my list should be the 4th smalle
COUNTBLANK to count how many 0s I h
=COUNTBLANK($A$4:$A$13)

That will give me a result of 3. My list w


to add incremental value of 1 as it goes d
=COUNTBLANK($A$2:$A$11)+ROWS($A$

To find the nth smallest number, we can u


be our COUNTBLANK & ROWS formula:
=SMALL(($A$4:$A$13<>"")*ROW($A$4:$

This formula above is good enough for an


referring to Row 4. Copy the formula dow

As you can see, we have been pressing F9


But we actually can park this array of valu
=INDEX(array, row_num, [column_num])
We normally fill in the row_num or colu
we were to put in 0 in either of them, it
=($A$4:$A$13<>"")*ROW($A$4:$A$13)

We can then put this formula inside the IN


=INDEX(($A$4:$A$13<>"")*ROW($A$4:$

And applying this back in the SMALL form


=SMALL(INDEX(($A$4:$A$13<>"")*ROW
We still have some loose ends to finish, b

So column C should be showing the text i


row 11, it is looking for the 11th smallest,
INDEX formula for us to return the row of
=INDEX($A$1:$A$11,
This is just to say from A1:A11, pick out th

Now, to handle the errors, we have find o


formulas that return blank cells. So we us
=COUNTIF($A$4:$A$13,">""")

This will return 7 as we have 7 non-blan


non-blank cells, return blank. Otherwise,
=ROWS($A$4:$A4)>COUNTIF($A$4:$A$1

This is a logical test that will return TRUE


blank in the TRUE statement & the long fo
8 will be greater than 7. Using IF:

=IF(ROWS($A$4:$A4)>COUNTIF($A$4:$A

The formula after the comma is of course


=IF(ROWS($A$4:$A4)>COUNTIF($A$4:$A
That ends it!

u can see here in A4:A13, there are some blank cells in between. And we want to use formulas to make it sh

of us who knows array formulas can probably easily do a formula to make a list without the blanks. But arra
ially if youre dealing with a huge file. So heres a method by this forum guru, Marcol, which which does not

f, we can see that what we need is to return rows 4, 5, 6, 8, 10, 11 & 13. These are the non-blank rows.

s do a formula that returns the row number; the ROW formula. So if my formula is:

return me the row number of A4, which is 4. But if you list a range of cells from A4:A13, click inside the fo
W($A$4:$A$13)
6;7;8;9;10;11;12;13}
u can see, it creates a list of numbers from Row 4 to Row 13.
W($A$4:$A$13)

row 7, 9 & 12 are blanks, we have to make sure these row numbers are shown as 0 instead. To do that, we
the cells are blanks:
4:$A$13<>""

, if you click inside the formula bar & press F9 to calculate, you will see that it creates a list of TRUEs & FALSE
means it is a blank:
E;TRUE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE}
TRUE in Excel is actually equivalent to the value 1 & FALSE is 0. So if we were to multiply this logical tes
the 0 for the blank cells.
$4:$A$13<>"")*ROW($A$4:$A$13)
6;0;8;0;10;11;0;13}

s is what actually happened. A4 for eg, is not a blank. The logical test will turn TRUE, and TRUE is equiv
e 4, so the multiplication will be 1*4, & returning 4. This continues until a cell which has blanks (i.e. A7
of it is 0. Whatever the row number is, 0 multiplies by any number will return a 0.
Logical Test
1
1
1
0
1
0
1

Equivalent to:
1
1
1
0
1
0
1

ROW formula
4
5
6
7
8
9
10

Multiplication
4
5
6
0
8
0
10

1
0
1

1
0
1

11
12
13

11
0
13

were to rank the numbers after the multiplication, 0 would be the smallest. 2nd & 3rd smallest numbers ar
on my list should be the 4th smallest row number, and the second value on my list should be the 5th, & so o
TBLANK to count how many 0s I have.
UNTBLANK($A$4:$A$13)

will give me a result of 3. My list will be incremental by 1 as it goes down (i.e. 4th smallest, 5th smallest, e
d incremental value of 1 as it goes down (i.e. 4th smallest, 5th smallest, etc). Thus, I can use the ROWS form
UNTBLANK($A$2:$A$11)+ROWS($A$4:$A4)

d the nth smallest number, we can use the SMALL formula. The array would be our logical test & the ROW nu
r COUNTBLANK & ROWS formula:
ALL(($A$4:$A$13<>"")*ROW($A$4:$A$13),COUNTBLANK($A$4:$A$13)+ROWS($A$4:$A4))

ormula above is good enough for an array formula. If you press CTRL + SHIFT + ENTER inside the formula ba
ng to Row 4. Copy the formula down & you should see it skip from row 6 to 8 as row 7 is a blank. Row 9 & 1

u can see, we have been pressing F9 inside the formula bar to get the results we want. These are array valu
e actually can park this array of values in the INDEX formula in order not to make this an array formula. The
EX(array, row_num, [column_num])
rmally fill in the row_num or column_num as a number equals or more than 1. This will return us a singl
ere to put in 0 in either of them, it will give us all the values of the array. Hope you recall this formula?
$4:$A$13<>"")*ROW($A$4:$A$13)

n then put this formula inside the INDEX formula & put a 0 in the row_num argument:
EX(($A$4:$A$13<>"")*ROW($A$4:$A$13),0)

pplying this back in the SMALL formula, you dont have to press CTRL + SHIFT + ENTER anymore:
ALL(INDEX(($A$4:$A$13<>"")*ROW($A$4:$A$13),0),COUNTBLANK($A$4:$A$13)+ROWS($A$4:$A4))
ll have some loose ends to finish, but the toughest part is over!

umn C should be showing the text in row 4 instead of the just the number 4. Also, the #NUM! error should
1, it is looking for the 11th smallest, but we only have 10 numbers from 4 to 13. Lets do the text first. Since
formula for us to return the row of the array we state. The ones in red are added to our existing formula:
EX($A$1:$A$11,SMALL(INDEX(($A$4:$A$13<>"")*ROW($A$4:$A$13),0),COUNTBLANK($A$4:$A$13)+ROW(A
s just to say from A1:A11, pick out the 4th row. Copy down & youll have them all filled up with text, but the

to handle the errors, we have find out how many cells are non-blank. COUNTA comes into mind, but this form
las that return blank cells. So we use this instead:
UNTIF($A$4:$A$13,">""")

will return 7 as we have 7 non-blank cells. Our 8th value is the one with error, so we can say that if the nth
lank cells, return blank. Otherwise, do the formula. To get the nth number, we can use ROW again. So:
WS($A$4:$A4)>COUNTIF($A$4:$A$13,">""")

s a logical test that will return TRUE or FALSE. Since ROWS($A$4:$A4) will return 1 & it is greater than 7, it
in the TRUE statement & the long formula we created, in the FALSE statement. This formula will only return
ll be greater than 7. Using IF:

OWS($A$4:$A4)>COUNTIF($A$4:$A$13,">"""),"",

rmula after the comma is of course the long formula we created.


OWS($A$4:$A4)>COUNTIF($A$4:$A$13,">"""),"",INDEX(A$4:A$13,SMALL(INDEX(($A$4:$A$13<>"")*(ROW($

use formulas to make it show a list without blanks in between like

ithout the blanks. But array formulas will slow down calculations,
rcol, which which does not use arrays.

are the non-blank rows.

A4:A13, click inside the formula bar & press F9 to calculate:

0 instead. To do that, we can do a simple logical test to find

ates a list of TRUEs & FALSEs. TRUE means the cell is not a blank, &

e to multiply this logical test with the ROW formula, we would be able

TRUE, and TRUE is equivalent to the value 1. The ROW of A4 is of


ell which has blanks (i.e. A7). The logical test turn FALSE, hence the

& 3rd smallest numbers are still the other 2 zeroes. So the first
st should be the 5th, & so on. To get the number 4, I can use

th smallest, 5th smallest, etc). Thus, I can use the ROW formula again
s, I can use the ROWS formula to add incremental value of 1

r logical test & the ROW number combined together. The k would

NTER inside the formula bar, 4 should appear. And thats actually
ow 7 is a blank. Row 9 & 12 is also excluded when copied down.

want. These are array values, mostly to combine with array formulas.
this an array formula. The arguments of the INDEX formula go like this:

. This will return us a single value from the array chosen. But if
e you recall this formula?

NTER anymore:
+ROWS($A$4:$A4))

, the #NUM! error should be removed. It will be appearing because in


ets do the text first. Since we have the row number, all we need is the
to our existing formula:
LANK($A$4:$A$13)+ROW(A1)))
filled up with text, but the last few with the #NUM! error

mes into mind, but this formula will fail if column A contains

o we can say that if the nth value is greater than the number of
n use ROW again. So:

1 & it is greater than 7, it will return FALSE. Our IF statement will put a
his formula will only return TRUE when it is at ROWS($A$4:$A11) where

($A$4:$A$13<>"")*(ROW($A$4:$A$13)-ROW($A$4)+1),0),COUNTBLANK($A$4:$A$13)+ROWS($A$4:$A4))))

$A$13)+ROWS($A$4:$A4))))

<-back

Sum up with Either Or in 2 Columns

dog or cat in Column A, red or blue in Column B, sum up Column C


dog
red
5
daddylonglegs
cow
blue
7
11
11
cat
blue
17
http://www.excelforum.com/excel-formulas-a
horse
blue
15
snake
red
5
dog
green
25

om/excel-formulas-and-functions/883499-need-to-calculate-the-average-for-a-column-based-on-values-in-two-o

d-on-values-in-two-other-columns.html

<-back

Complicated Number Extraction

When there are 5 digits: The last 3 digits before the dash (or end of the string, if no dash). When ther
ABCDEFGHIJK60120-200
ABCD1360
ABCD13160-100
ABCDEFGH13160
ABCDEFGH13060

Err:504
Err:504
Err:504
Err:504
Err:504

=FIND("-",A6&"-")-1
For those with existing
it with a dash behind so
"ABCDEFGHIJK60120-20
and in A7:
"ABCD1360-"

=LEFT(A6,
A LEFT formula is then
there are 2 dashes beca
text.
"ABCDEFGHIJK60120"
"ABCD1360"

=RIGHT(LEFT(A6,FIND(
by stating an array con
{"60120","0120","120"

=--RIGHT(LEFT(A6,FIND
Using LEFT, RIGHT or M
to numbers. Notice the
{60120,120,120}

=--ISNUMBER(
Using ISNUMBER will de
"D1360"
This would be resulting
{TRUE,TRUE,TRUE}
the double negation the
{1,1,1}

=MATCH(1
The MATCH formula loo
the 1st one is 0 or FALS

=INDEX(RIGHT(LEFT(A
in the array portion of t
{3,2,2} characters inst

no dash). When there are 4 or less digits: The last 2 digits before the dash (or end of the string, if no dash)

=FIND("-",A6&"-")-1
or those with existing dashes, the above formula would return the length before the dash. For those without, th
with a dash behind so that there would be no error. So it's actually looking a dash for this in A6:
ABCDEFGHIJK60120-200-"

ABCD1360-"

=LEFT(A6,FIND("-",A6&"-")-1)
LEFT formula is then added to obtain all the text before the dash. FIND would return the position of the 1st das
here are 2 dashes because we added A6&"-", it returns everything before the 1st dash. And for the case of A7, i

ABCDEFGHIJK60120"
ABCD1360"

=RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})
y stating an array constant of {5,4,3}, you can actually extract 3 diferent lengths of 5, 4 & 3 using the RIGHT fo
"60120","0120","120"}

=--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})
sing LEFT, RIGHT or MID automatically makes it a text even if you have a cell of pure numbers. Using the doubl
o numbers. Notice the absence of double quotes if you press F9 to calculate
60120,120,120}

=--ISNUMBER(--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3}))
sing ISNUMBER will determine if those results are indeed numbers. A6 has no problem, but extracting 5 chars f

his would be resulting in a FALSE because it's not a number. For A7, the results would be:
TRUE,TRUE,TRUE}
he double negation then makes it:

=MATCH(1,--ISNUMBER(--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})),0)
he MATCH formula looks for 1 in the array above. Hence it returns 1 for A6 as it finds the 1st instance of 1. for A
he 1st one is 0 or FALSE.

=INDEX(RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{3,2,2}),MATCH(1,--ISNUMBER(--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),
the array portion of the INDEX formula, something similar is used. But this time, instead of extracting {5,4,3}
3,2,2} characters instead. So we extract 3 chars before the dash if 5 characters before it are all numbers. Othe

string, if no dash)

For those without, the formula combines

osition of the 1st dash, so in the case where


d for the case of A7, it returns the original

3 using the RIGHT formula. So the results are:

ers. Using the double negation converts it back

extracting 5 chars from the right of A7 would be:

st instance of 1. for A7, it would return 2, because

,FIND("-",A6&"-")-1),{5,4,3})),0))
f extracting {5,4,3} chars, we extract
re all numbers. Otherwise, we the last 2 chars.

<-back

SUMIF using multiple Criteria


Sum up if Column A equals "BOLIVIA" or "BRASIL" or "PERU"
bolivia
10
11
peru
20
spore
30
brasil
12
bolivia
1
brasil
3

Explanation added: Jun 2013

=SUMIF($A$5:$A$10,{"BOLIVIA","BRASIL","PERU"},$B$5:$B$10)
by putting the curly brackets with multiple criteria there, you are actually doing multiple SUMIF for
press ENTER with that, it will give you the SUMIF result of the 1st criteria; Bolivia. If you select tha
to calculate, you will see that 3 individual SUMIF results appear
{11,15,20}
=SUM(SUMIF($A$5:$A$10,{"BOLIVIA","BRASIL","PERU"},$B$5:$B$10))
to add those results, we simply need to place a SUM In front

ally doing multiple SUMIF for the diferent criteria. If you simply
ria; Bolivia. If you select that portion of the formula & press F9

<-back

Lookup Unsorted List & Return Next Highest value


Category
B
A
A
B
B
A

Value

Result
9
28
25
3
15
18

100
120
200
50
150
170

Category
A
B

Value

Result
20
13

200
150

Category A of Value 20 is between the list of Value 18 & 25. The formula will pick the bigger number
Category B of Value 13 is between the list of Value 9 & 15. The formula will pick the bigger number b
Explanation added: Jun 2013
=$A$5:$A$10=E5
This is the first of our 2 logical tests. We need to find out if A5:A10 is equals to the category we want
to calculate this portion, you'll get:
{FALSE;TRUE;TRUE;FALSE;FALSE;TRUE}
Only the 2nd, 3rd & 6th one are Category A
=$B$5:$B$10>=F5
Our next logical test is to check if B5:B10 is greater or equals to the value in F5. So the results are:
{FALSE;TRUE;TRUE;FALSE;FALSE;FALSE}

=IF($A$5:$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10))
If we combine both the logical tests with the IF, it will return the values in B5:B10 only when it meets
logical tests. So in our case, only the values in B6 & B7 will show up. The rest will turn FALSE becaus
{FALSE;28;25;FALSE;FALSE;FALSE}
This part is our lookup_array portion for the MATCH formula.

=MIN(IF($A$5:$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10)))
We can then use the same formula & find the minimum of the above numbers using MIN. Between 28
minimum number. that makes up the lookup_value for the MATCH formula. So we are looking for "25"
{FALSE;28;25;FALSE;FALSE;FALSE}

=MATCH(MIN(IF($A$5:$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10))),IF($A$5:$A$10=E5,IF($B$5:$B$
By using a MATCH formula, we can find the position of 25. since it's the 3rd value, it returns 3.

=INDEX($C$5:$C$10,MATCH(MIN(IF($A$5:$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10))),IF($A$5:$A
Combining with INDEX, we are saying we want the 3rd value (from the MATCH formula) within C5:C10

k the bigger number between the 2.


the bigger number between the 2.

he category we want in E5. so if you press F9

So the results are:

only when it meets both the criteria of the


ll turn FALSE because it fails the logical test/s.

ing MIN. Between 28 & 25, 25 would be the


e are looking for "25" inside the array of

$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10)),0)
e, it returns 3.

$B$10))),IF($A$5:$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10)),0))
mula) within C5:C10.

<-back

Get Time Diff No Matter Which Cell is bigger


6:00 AM
12:00 PM

12:00 PM
6:00 AM

6:00:00
18:00:00

Explanation added: Jun 2013


=B4-A4
First, you must understand Times are reco
take a later time minus an earlier time, Ex
smaller decimal. But if you copy that dow
are negative or too large display as ####

The MOD formula works like this; we have


=MOD(13,5)
It returns you the remainder after 13 (num
=Number - Divisor * INT(Number/Divisor)
so it's:
=13-5*INT(13/5)
INT is taking just the integer of the numbe

=MOD(B4-A4,1)
If you take a later time minus an earlier ti
Using MOD with a positive decimal numbe
=Number - Divisor * INT(Number/Divisor)
=0.25-1*INT(0.25/1)
Rounding 0.25 down to the nearest intege
=0.25-1*0

But if you take an earlier time minus a lat


=-0.25-1*INT(-0.25/1)
This time, rounding down a negative 0.25
=-0.25-1*-1
that returns a result of 0.75. Convert that

n added: Jun 2013

st understand Times are recognised as decimals in Excel. 12 pm for eg, is 0.5 if you format the cells as Gene
ime minus an earlier time, Excel has no problems doing that. You can try plainly using B4-A4. That is equiva
mal. But if you copy that down use B5-A5, Excel does not accept that in Time format. It shows a bunch of #s
or too large display as ######.". That is because this time, you are taking a smaller decimal (6 am) minu

mula works like this; we have a number & a divisor. It's much straightforward if they are integers. Say we ha

u the remainder after 13 (number) is divided by 5 (divisor). The remaining number that cannot be divided by
Divisor * INT(Number/Divisor)

just the integer of the number we input. 13 divided by 5 is 2.6. So it takes the interger 2. so it's 13-5*2

later time minus an earlier time, it will retain the diference of the positive decimal number. So this is actual
with a positive decimal number will return the same value. You can try calculating by using what I showed ea
Divisor * INT(Number/Divisor)

5 down to the nearest integer is 0. Hence:

ke an earlier time minus a later time, it will be a negative decimal number. The eg in C5 is doing so by taking
T(-0.25/1)
unding down a negative 0.25 is -1. Therefore:

a result of 0.75. Convert that to time & that gives us 18 hours.

you format the cells as General, because it's half a day. So if you
y using B4-A4. That is equivalent to a bigger decimal minus a
rmat. It shows a bunch of #s & tells you "Dates and times that
smaller decimal (6 am) minus a bigger decimal (12 pm).

they are integers. Say we have this below

ber that cannot be divided by 5 is 3. It is essentially using:

interger 2. so it's 13-5*2

mal number. So this is actually 0.5 minus 0.25


ng by using what I showed earlier:

eg in C5 is doing so by taking 0.25 minus 0.5, returning -0.25

<-back

Non-breaking space
Char(160) non-breaking space

http://en.wikipedia.org/wiki/Non-breaking_space

Sometimes, your cells has spaces that you cannot seem to use TRIM to remove. This might be the no
abab<-TRIM of no use
To remove it, substitute the non-breaking space with blanks
abab

Alternatively, if you have to do it just once, go inside the cell where you have the non-breaking space
press CTRL + H to Find & Replace. Paste the character under Find What & replace it with nothing.

This might be the non-breaking spaces. For eg:

non-breaking space. Copy a single character of it & press ESC


ce it with nothing.

<-back

Change single digits to Double


A-10-1
A-1-1
A-2-1

A-10-1
A-1-1
A-2-1

Explanation added: Jun 2013


=COUNTIF(A4,"*-?-*")
We can first find out if the middle portion contains 1 o
is indicating that any unknown single character. So b
between, followed by another dash, in between any c

=SUBSTITUTE(A4,"-",IF(COUNTIF(A4,"*-?-*")
If there are such instances where the middle portion
zero in front. In the scenario where no such instance
instance_num is to say that we only want to substitut
=COUNTIF(A4,"*-?")
This is similar to our first one, but concentrating just
that.

=SUBSTITUTE(SUBSTITUTE(A4,"-",IF(COUNTIF(A4,"*So now, basing on the new substituted text (with 2 di


we substitute "-" with a "-" when the last portion has
1st.

he middle portion contains 1 or 2 digits. Using the asterisk is for wildcards; finding any number of characters
known single character. So by using "*-?-*", we are finding anything that has a dash, a single character (the
other dash, in between any characters (the asterisk).

COUNTIF(A4,"*-?-*"),"-0","-"),1)
es where the middle portion contains only 1 digit, we want to substitute the "-" with "-0". That makes all sing
nario where no such instances are found (2 digits in the middle), we simply substitute the "-" with a "-" (i.e. n
hat we only want to substitute the first dash & not touch the rest.

t one, but concentrating just on the last portion. It is looking for a dash & ending with a single character afte

UTE(A4,"-",IF(COUNTIF(A4,"*-?-*"),"-0","-"),1),"-",IF(COUNTIF(A4,"*-?"),"-0","-"),2)
ew substituted text (with 2 digits in between), we again substitute the "-" with a "-0" if the last portion is a si
"-" when the last portion has 2 digits. Our instance_num is now 2 because we only want to change the 2nd d

ng any number of characters. Using a question mark


dash, a single character (the question mark) in

with "-0". That makes all single digits contain a


titute the "-" with a "-" (i.e. no changes). The

g with a single character after any characters before

"-0" if the last portion is a single digit. Similarly,


nly want to change the 2nd dash & not touch the

<-back

Number of a Particular Day Between 2 Dates


Mon
1-Jan-13 27-Jan-13

Tue
3

Wed
4

Thu
4

Fri
4

Explanation added: Jul 2013


http://www.youtube.com/watch?v=p9YOlYL6X7A
Solution: Barry Houdini
http://www.mrexcel.com/forum/excel-questions/542039-what-formula-doing.html

<-back

Number of Workdays (Mon-Sat)

http://www.mrexcel.com/forum
Barry Houdini Excel 2010 Explanation in:
1-Jan-13 27-Jan-13
23 #NAME?
"0000001" - starts from Mon; 0 means to include

ttp://www.mrexcel.com/forum/excel-questions/542039-what-formula-doing.html
rom Mon; 0 means to include while 1 is to exclude. In this case, only exclude Sun.

<-back

List items that meet criteria (Aggregate)


Dates
1/1/2013
2/5/2013
2/2/2013
3/3/2013
4/1/2013
4/30/2013
4/30/2013
5/1/2013
5/15/2013

Name No Action
John
Michelle
1
Dylan
Jack
1
Dave
Mike
1
Doran
1
Joshua
Anthony
1

My Method (Array)
5-Feb-13 Michelle
3-Mar-13 Jack
30-Apr-13 Mike
30-Apr-13 Doran
15-May-13 Anthony

My Method (Non-Array)
5-Feb-13 Michelle
3-Mar-13 Jack
30-Apr-13 Mike
30-Apr-13 Doran
15-May-13 Anthony

Teethless Mama (Aggregate only in 2010)

y in 2010)

<-back

Convert fractions to decimals

15/2

daddylonglegs
7.5

Excel recognises integer fraction format like 1 1/2 will be

mat like 1 1/2 will be 1.5

<-back

Rounddown time to the hour with 4 digits

12:20 AM
1:50 AM

Mine
0000
0100

Teethless mama
0000
0100

Explanation added: Jul 2013

n added: Jul 2013

<-back

Rank Name according to values in descending order


Ep

US
3

IL

IL
5

Mex

DK
11

US

Mex
5

DK

9
Ep

Excelisfun
http://www.youtube.com/watch?v

outube.com/watch?v=BzL68bIM7U0&list=PLC3D5DEE0852CDB92

<-back

Get Unique List from Multiple Columns

MON
TUES
WED
THU
FRI

DAVE
AM
Support
Project A
Project A
Project B
Project B

PM
Support
Project A
Project A
Project B
Project B

Link given by Pete_UK


Project
Periods in Schedule
Support
Project C
Project A
Project B
Err:504

SUE
AM
Project C
Support
Support
Project B
Project B

PM
Project C
Support
Support
Project B
Project B

JOHN
AM
Project C
Project A
Project A
Support
Support

PM
Project C
Project A
Project A
Support
Support

MICHAEL
AM
Project C
Support
Support
Project B
Project B

http://www.get-digital-help.com/2009/03/16/unique-valu

PM
Project C
Support
Support
Project B
Project B

9/03/16/unique-values-from-multiple-columns-using-array-formulas/

<-back

Sum up with conditions, stop when Amt exceeds 600


Sum up Amts that is "T6673758" & before 31 Dec 12 but stop when Amt exceeds 600
ID
Name
Country
Date
Amt
Doe, Jane USA
9/2/2012
109.31
T6673758
Doe,
Jane
USA
9/4/2012
118.6
ABC
Doe, Jane USA
10/3/2012
145
T6673758
Doe, Jane USA
10/22/2012
240
T6673758
Doe, Jane USA
11/1/2012
96
T6673758
Doe,
Jane
USA
12/12/2012
77.4
T6673758
Doe, Jane USA
1/1/2013
21.85
T6673758

mt exceeds 600
Haseeb A
#VALUE!

Explanation added: Jul 2013

What the formula does here is create many SUMIFS results that has an increme
sums up G6 if A6 is "T6673758" & E6 is less than 31 Dec 2012. Result would be
by 1 row; sum up G6:G7 if A6:A7 is "T6673758" & E6:E7
is still 109.31 because row 7 did not meet the criteria. It continues until row 12 &
results as such:
{109.31;109.31;254.31;494.31;590.31;667.71;667.71}

As the numbers are in an ascending order, we can use the LOOKUP formula to s
When it fails to find an exact match, it will return the last value smaller than 600.
590.31.

=OFFSET(G6,,,ROW(G6:G12)-ROW(G6)+1)
This is how to make multiple incremental rows for the different results. OFFSET
For the height, ROW(G6:G12) will return:
{6;7;8;9;10;11;12}
We need it to return 1 to 7 for it to become G6:G6, G6:G7, and so on. You can t
{0;1;2;3;4;5;6}
Lastly, just add +1 to make it:
{1;2;3;4;5;6;7}
The concept is the same for the other 2 parts:
OFFSET(A6,,,ROW(A6:A12)-ROW(A6)+1)
OFFSET(E6,,,ROW(E6:E12)-ROW(E6)+1)

SUMIFS results that has an incremental row. So it first


than 31 Dec 2012. Result would be 109.31. It then increases
58" & E6:E7 is less than 31 Dec 2012. Result for this
e criteria. It continues until row 12 & thus gives 7

we can use the LOOKUP formula to search a value of 600.


urn the last value smaller than 600. And that would be

ws for the different results. OFFSET will start at G6.

G6:G6, G6:G7, and so on. You can then -ROW(G6):

<-back

Check if Range of Dates fall within another Range of Dates


Start
2-Jan-13
25-Dec-12
1-Feb-13
25-Dec-12
1-Feb-13

End
3-Jan-13
26-Dec-12
10-Feb-13
28-Dec-12
5-Feb-13

3
0
0
0
0

E.Start
E.End
1-Jan-13 31-Jan-13
3-Jan-13 31-Jan-13
29-Dec-12 2-Jan-13

<-back

Get list of 5 highest total cumulative values


value

id
1
2
3
4
5
6
3

ID
100
125
90
200
150
120
90

Total
4
#N/A
5
2
6

by Ron Coderre
200
180
150
125
120

explained too, by Ron

The FREQUENCY function a

referenced value or that


generate 8 values. Cons

The FREQUENCY section re


A_Item
Freq_Calc
1

3
blank

0 <-dupe,
0 <-extra

Basically, that formula wor

This part calculates the list


INDEX(SUMIF($A$5:$A$12

This part returns the nth la


LARGE(INDEX(SUMIF($A$

xplained too, by Ron Coderre (with some editing to change cell references)

he FREQUENCY function always tacks on an additional calculated value for items that are greater than the max

ferenced value or that are less than the minimum referenced value. So, while FREQUENCY references A5:A11 (
enerate 8 values. Consequently, I needed to extend the other references by 1 cell (A5:A12).

he FREQUENCY section resolves to this: {1;1;2;1;1;1;0;0}...8 values arranged this way:


_Item
Freq_Calc

lank

1
1
2
1
1
1
0 <-dupe, so ignored
0 <-extra value

asically, that formula works this way INDEX(A5:A12,MATCH(Largest_Total_Col_A_Item,List_of_Totals_by_Col_A_Item,0))

his part calculates the list of totals...Tacking on some padding for duplicates "+1/ROW($A$5:$A$12)":
NDEX(SUMIF($A$5:$A$12,(FREQUENCY($A$5:$A$11,$A$5:$A$11)>0)*$A$5:$A$12,$B$5:$B$12)+1/ROW($A$5:$A$12),0

his part returns the nth largest of those totals, based on the rank value in Col_D:
ARGE(INDEX(SUMIF($A$5:$A$12,(FREQUENCY($A$5:$A$11,$A$5:$A$11)>0)*$A$5:$A$12,$B$2:$B$9)+1/ROW($A$5:$A

n the max

references A5:A11 (7 cells), it will

s_by_Col_A_Item,0))

1/ROW($A$5:$A$12),0)

B$9)+1/ROW($A$5:$A$12),0),D1)

<-back

VLOOKUP backwards
Amount
20,000
13,000
18,000

Listed
Yes
Yes
No

Company
A
B
C

solution by abousetta
Company Amount
B
13000

Im sure youve been


But what if the Compa

The usual workaround


other way is to learn t
CHOOSE. Heres wha
=CHOOSE(index_num

A simple scenario wou


will pick up A5; becau
=CHOOSE(
And if I were to put in
=CHOOSE(

I can also pick up both


so lets add a SUM to
=SUM(CHOOSE({1,2}

So if we go back to ou
forcing whatever colu
Pretty brilliant eh? I w

m sure youve been told the lookup_value in the VLOOKUP formula must always be on the left & the data you re
ut what if the Company is on the right side of Profits?

he usual workaround is to insert a column before A & copy the Company column over. Then you can do the usu
ther way is to learn the seemingly more complex INDEX & MATCH. Heres a 3rd option by just learning a simple
HOOSE. Heres what you need to input for the formula:
=CHOOSE(index_num, value1, [value2], )

simple scenario would be to return A5 or A6. The index_num decides which value would be picked up. So if my
ill pick up A5; because thats the value1 I input.
=CHOOSE(1,A5,A6)
nd if I were to put in 2 as the index_num, it will pick up A6.
=CHOOSE(2,A5,A6)

can also pick up both of the numbers by adding the curly brackets here. But picking up 2 numbers in a cell don
o lets add a SUM to it. It will therefore pick up A5 AND A6 to sum them up.
=SUM(CHOOSE({1,2},A5,A6))

o if we go back to our VLOOKUP case & put in the column for us to look up as value1, and the result column as v
orcing whatever column that is on the right, to the left.
retty brilliant eh? I would still stick to INDEX & MATCH, but I thought this was pretty interesting.

eft & the data you require on the right.

n you can do the usual VLOOKUP. The


ust learning a simple formula called

e picked up. So if my index_num is 1, it

umbers in a cell dont make sense to Excel,

he result column as value2, we are actually

<-back

Inserting Something In The Middle Of Text


Inserting A Semicolon After the comma & 2 letters
BOSSIER CITY, LAARCADIA, LA
BOSSIER CITY, LACREW LAKE, LA
BOSSIER CITY, LACULLEN, LA
BRANDON, MSJACKSON, MS
BRANDON, MSVICKSBURG, MS
BROOKELAND, TXSHREVEPORT, LA
BROOKSHIRE, TXFLATONIA, TX

solution by NBVC
BOSSIER CITY, LA;ARCADIA, LA
BOSSIER CITY, LA;CREW LAKE, LA
BOSSIER CITY, LA;CULLEN, LA
BRANDON, MS;JACKSON, MS
BRANDON, MS;VICKSBURG, MS
BROOKELAND, TX;SHREVEPORT, LA
BROOKSHIRE, TX;FLATONIA, TX

<-back

Find Position of 1st Upper Case


Solution found by: litrainer
bAc

CHAR(65) will return yo


{65;66;67;68;69;70;71
and with CHAR(ROW(6
{"A";"B";"C";"D";"E";"F"

the SUBSTITUTE formula


SUBSTITUTE(A1,CHAR(R
so if A1 contains "1bZc"
{"1bZc";"1bZc";"1bZc";

note that results appear


SUBSTITUTE(A1,CHAR(R
this makes every result
{"1bZc0";"1bZc0";"1bZc

so if you find "0", it will


{5;5;5;5;5;5;5;5;5;5;5

and the MIN formula wil

HAR(65) will return you "A" &CHAR(90) will return you "Z". so if you put in ROW(65:90), it will return these values fro
65;66;67;68;69;70;71;72;73;74;75;76;77;78;79;80;81;82;83;84;85;86;87;88;89;90}
nd with CHAR(ROW(65:90)), it will return "A" to "Z":
"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z"}

e SUBSTITUTE formula will then substitute all the upper case letters above if found with a zero.
UBSTITUTE(A1,CHAR(ROW(65:90)),0)
o if A1 contains "1bZc", it will return:
"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"

ote that results appear 26 times, each time substituting a single letter. 1st one substituting "A" with "0". it doesnt find any,
UBSTITUTE(A1,CHAR(ROW(INDIRECT("65:90"))),0)&0
is makes every result have a "0" behind:
"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0

o if you find "0", it will return:


5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;3}

nd the MIN formula will give you the last result. hope that helps

return these values from 65 to 90:

1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1b0c"}

"0". it doesnt find any, goes to "B", then "C", & so on until the last entry. it substitutes "Z" with a "0" & becomes "1b0c". b

bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";

" & becomes "1b0c". but FIND has a problem, because the rest of the results do not have "0" & will return #VALUE error.

c0";"1bZc0";"1bZc0";"1b0c0"}

return #VALUE error. so to counter that, the &0 is added.

<-back

Find number & extract the rest from there


abc 1. xyz
soppppp2c

=FIND({0,1,2,3,4,5,6,7,8,9},A4)
The 10 numbers that exist are 0 to 9. if
{#VALUE!,5,#VALUE!,#VALUE!,#VALUE!
it tries to find "0", couldn't find it & thus

=FIND({0,1,2,3,4,5,6,7,8,9},
But if we were to combine "0123456789
{11,5,13,14,15,16,17,18,19,20}

=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A4&"0
Since we put the 10 numbers behind, th

=MID(A4,MIN(FIND({0,1,2,3,4,5,6,7,8,9
Once we know the starting position to e
safe bet would be to put the LEN formul

2,3,4,5,6,7,8,9},A4)
ers that exist are 0 to 9. if we were to find 0 to 9 in A4, it will have a bunch of errors because 1 is the only num
#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!}
d "0", couldn't find it & thus returns VALUE. It then finds "1" in the 5th position. The rest also couldnt be found

2,3,4,5,6,7,8,9},A4&"0123456789")
e to combine "0123456789" to A4, every single number can be found.
15,16,17,18,19,20}

{0,1,2,3,4,5,6,7,8,9},A4&"0123456789"))
the 10 numbers behind, the original number existing in A4 would in the smallest number found above (the 5th

N(FIND({0,1,2,3,4,5,6,7,8,9},A4&"0123456789")),LEN(A4))
w the starting position to extract the text, we can use MID & the number of characters to extract are everything
ld be to put the LEN formula to count the number of characters in A4

use 1 is the only number that can be found there.

so couldnt be found & returned VALUE.

ound above (the 5th character)

xtract are everything from the number onwards. A

<-back

Lookup Value / Table Array in 2 different Columns/Range


Lookup value can be in column G or H. Table array can be in A6:B8 or
D6:E8.
aaa
1a
ddd
4d
eee
bbb
2b
eee
5e
zzz
ccc
3c
ff
6f
ccc

by DonkeyOte
#N/A
#N/A
#N/A

Explanation added: Sep 2013


http://www.excelforum.com/excel-general/699168-nested-vlook-and-mat
This was the original link shared with me by Pike. DonkeyOte was lookin
values. I made some changes here to refer to diferent ranges under the

=VLOOKUP(G6&H6,$A$6:$B$8,2,0)
Since the lookup_value for the VLOOKUP formula can either be in Column
the 2 cells together. It is just a simple VLOOKUP to search in A6:B8 if "ee
return the corresponding row in B6:B8. "eee" does not exist in A6:B8, so
=VLOOKUP(G6&H6,$D$6:$E$8,2,0)
Another VLOOKUP formula is done, but now to search in D6:E8. "eee" is
under cell E7.

Instead of using a long IF & ISNA formula, we can use the CHOOSE formu
formula to pick the last non-error result. A simple CHOOSE formula work
=CHOOSE(1,E6,E7,E8)
We have 3 values above; E6, E7 & E8. With the index_num as "1", it will
=CHOOSE(2,E6,E7,E8)
It will then pick the 2nd value; "5e". But if you put in array constants (th
=CHOOSE({1,2,3},E6,E7,E8)
This actually shows all 3 values. You can't see it by pressing ENTER beca
F2 on the cell with this formula & press F9 to calculate. You should see:
={"4d","5e","6f"}

=CHOOSE({1,2,3},"",VLOOKUP(G6&H6,$A$6:$B$8,2,0),
And that is how we are going to store the 2 VLOOKUP formulas. We are a
This comes in handy when the 2 VLOOKUP formulas cannot find the looku
in cell I7, where "zzz" cannot be found in A6:A8 or D7:D8. These are the
{"",#N/A,"5e"}
{"",#N/A,#N/A}
{"","3c",#N/A}

=LOOKUP(REPT("Z",255),CHOOSE({1,2,3},"",VLOOKUP(G6&H6,$A$6:$B
By using a lookup_value of 255 Zs, it will ensure we are looking for the la
formula ignores errors, so from the 3 results above, it will return the last
as text & that's why blank was returned for cell I7 when there are 2 #N/A

68-nested-vlook-and-match-functions.html
e. DonkeyOte was looking at diferent sheets to pick up the
diferent ranges under the same sheet instead.

la can either be in Column G or Column H, we can combine


P to search in A6:B8 if "eee" is in A6:A8, and if it is,
oes not exist in A6:B8, so it returns an #N/A here.

search in D6:E8. "eee" is found this time & would return "5e"

an use the CHOOSE formula to present the 2 results & LOOKUP


ple CHOOSE formula works like this:

e index_num as "1", it will return the 1st value; "4d". If you put it as:

put in array constants (the curly brackets) to show values 1 to 3:

it by pressing ENTER because 1 cell can't show the 3 results. Press


alculate. You should see:

$B$8,2,0),VLOOKUP(G6&H6,$D$6:$E$8,2,0))
OOKUP formulas. We are also adding a blank here as the 1st value.
mulas cannot find the lookup_value & both returns #N/A. It happens
or D7:D8. These are the following results for I6:I8 respectively:

VLOOKUP(G6&H6,$A$6:$B$8,2,0),VLOOKUP(G6&H6,$D$6:$E$8,2,0)))
e we are looking for the last possible text that exist. The LOOKUP
ove, it will return the last text available (blanks also considered
I7 when there are 2 #N/As).

<-back

Variable Cost for Different Qty Range


Qty

by AceXL
200,000
400,000
700,000
1,100,000

2000
3000
4000
5000
1.
2.
3.
4.

for
for
for
for

the
the
the
the

range
range
range
range

of
of
of
of

Equivalent to:
200000
400000
700000
1100000

1 - 2000 - cost per unit will be 100


2001-3000 - cost per unit will be 200
3001 - 4000 - cost per unit will be 300
4001 and up - cost per unit will be 400

Link for the explanation of logic shared by: Tony Valko


http://mcgimpsey.com/excel/variablerate.html

<-back

No of Days between 2 Dates Within A List of Dates


by Marcol
Relevant Year

YEAR: ONE
YEAR: TWO
YEAR: THREE
YEAR: FOUR
YEAR: FIVE
YEAR: SIX
YEAR: SEVEN

From

15-Mar-12
15-Mar-11
15-Mar-10
15-Mar-09
15-Mar-08
15-Mar-07
15-Mar-06

To

14-Mar-13
14-Mar-12
14-Mar-11
14-Mar-10
14-Mar-09
14-Mar-08
14-Mar-07

Total Number of
Days Out of
Country

Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504

Date of Exit

18-Aug-05
18-Apr-06
3-Sep-08
12-Aug-09
6-Mar-12
1-Sep-12
1-Sep-09

Date of
Entry

8-Sep-05
18-May-06
1-Oct-08
26-Aug-09
25-Mar-12
11-Sep-12
20-Sep-09

Total Number
of Days Out of
Country

20
29
27
13
18
9
18

<-back

Sorting Numbers/Text Without Blanks


Text & Numbers
Orange
Apple

22
111

Mango
111
Grapes
22
Text or Numbers Only
Orange
Apple
Mango
Grapes

Apple
Grapes
Mango
Orange
#VALUE!

Apple
Grapes
Mango
Orange
#VALUE!

Source:
http://www.get-digital-help.com/2009..

et-digital-help.com/2009...mula-in-excel/

<-back

Sum Up Numbers Separated by Dash

22-33-34-35-36
08-28-29-30-35
01-18-23-33-35

Excel 2003 & above


solution by Tony Valko
0
0
0

Excel 2007 & above


solution by Ghozi Alkatiri
0
0
0

Explanation added: Nov 2013


Tony's Formula
="-"&G6
1 character after the "-" is where the numbers to add up are. see first dash, add 33. see second dash
first adds a "-" to G6 so that all are equal.

=COLUMN(1:1)
COLUMN(A1) returns 1. that's the column number of A1. COLUMN B1 returns 2. if you use COLUMN(A
{1,2,3}
COLUMN(1:1) will therefore return 1 to 16,384 if you are using xlsx extension (up to Column XFD)

=MID("-"&G6,COLUMN(1:1),1)
this part is to break up all the characters into parts of 1 each. so since we combined "-" with G6, we a
"-22-33-34-35-36"
and in here, it's saying, from that text above, start from the 1st character (using COLUMN), and 1 char
until 16,384 characters. the results are something like:
{"-","2","2","-","3","3","-","3","4","-","3","5","-","3","6","","","",..........}

MID("-"&G6,COLUMN(1:1),1)="-"
this is to check if the extraction is a "-". so only if it is a "-", the formula will do a MID formula extracti
{TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,........

=FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)
FIND is used to find a dash in this text below using G6 combined with a dash behind.
"22-33-34-35-36-"
the start_num of FIND is also used using COLUMN(1:1). 1 is simply to start finding "-" in the 1st chara
the formula, it minus 1 character for the 1st extraction using COLUMN(1:1). so 3-1 is 2. 6 would be d
always 2 characters for this case. it will roughly look like:
{2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,#VALUE!,#VALUE!,......}
VALUE error is due to "-" not being found any more after 15 characters.

=MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1))
the first extraction would be from the text in G6, start from the 1st character (using COLUMN again).
the 4th extraction would again be from text in G6, starting from 4th character (since COLUMN will give
in summary:
{"22","2","","33","3","","34","4","","35","5","","36","6","",#VALUE!,#VALUE!,#VALUE!}

2 things here; these numbers are actually texts with the double quotes. hence we can't add them up.

=--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))
adding the double negatives will make all the texts inside the brackets numbers, if they are indeed ar
explain this

=SUM(IF(MID("-"&G6,COLUMN(1:1),1)="-",--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))using the logical test we did in the inital stage, we can extract those numbers ONLY IF the single chara

Ghozi Alkatiri

Excel 2010
solution by XOR LX
#NAME? =EVALUATE(SUBSTITUTE('54'!$A5,"-","+"))
#NAME?
#NAME?

add 33. see second dash, add 34, & so on. but the first number is missed out because there is no dash in fron

ns 2. if you use COLUMN(A1:C1), it returns all the column numbers in that range like this:

n (up to Column XFD)

ombined "-" with G6, we are looking at this text below:

sing COLUMN), and 1 character long. but since COLUMN was used, it continues to extract form the 2nd charact

do a MID formula extraction in the next part. it will become TRUEs & FALSEs:
E,TRUE,FALSE,FALSE,...............}

h behind.

finding "-" in the 1st character. that will return 3. if i were to start finding in the 4th character, the next "-" is in
so 3-1 is 2. 6 would be deducting 4, because we're doing the when we start finding in the 4th character, COLU

r (using COLUMN again). and the number of characters 2 since FIND returns that. that gives us 22 (the 1st num
er (since COLUMN will give 4) & a length of 2 characters again, obtained by FIND. that gives us 33 (the 2nd num

#VALUE!}

nce we can't add them up. also, notice that we don't want some of those numbers, namely the 2nd, 3rd, 5th, 6t

bers, if they are indeed are numbers. the 0& is to add a 0 in front of those numbers. not sure why is that neces

"-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))))
rs ONLY IF the single character we extracted are the "-".

ere is no dash in front of 22. hence, the formula

orm the 2nd character, 3rd character & so on

ter, the next "-" is in character 6. at the end of


4th character, COLUMN would become 4. so it's

es us 22 (the 1st number we want to add).


s us 33 (the 2nd number we want to add).

the 2nd, 3rd, 5th, 6th, etc numbers.

ure why is that necessary. maybe Tony can

<-back

Lookup & Return Picture

MyAvatar

MyAvatar

Excel2013

Super Excel
Explanation added: Nov 2013
1. Do up an INDEX & MATCH formula to return the pictures in F4:F6 based on A4's value.
=INDEX($F$4:$F$7,MATCH($A$4,$E$4:$E$6,0))

2. Make sure every cell reference is fixed because we are going to place it in the Named Range. Press

3. Click on New & put in a name for it. I'm going to name it PicX & in "Refers to", put in the INDEX & M
4. In Excel 2007, go to Insert tab -> Object -> Bitmap Image. Close the Paint window.
In other versions, copy any picture from F4:F6 & paste it in B4

5. Click on the picture in B4 & in the formula bar on top, type in equals & the Named Range you gave.
=PicX
Click ENTER

*A method that will work for all versions is to use the Camera Tool for Step 4. You need to enable that

ased on A4's value.

ce it in the Named Range. Press CTRL + F3

Source:
Excel 2010
http://www.youtube.com/watch?v=CEM0pp5S

Excel 2007
http://www.youtube.com/watch?v=W_GBoDkb

"Refers to", put in the INDEX & MATCH formula

he Paint window.

s & the Named Range you gave.

Step 4. You need to enable that in your Quick Access Toolbar. (the pic in B5 is from Camera Tool)

/watch?v=CEM0pp5SjMU

/watch?v=W_GBoDkb2pI

Вам также может понравиться