0% found this document useful (0 votes)
93 views155 pages

Excel Tricks Learned

1. Use the MAX function with an array of row or column numbers multiplied by a logical test to determine if the cell is empty. 2. For rows, test if each cell is empty using ISBLANK and multiply the row number. 3. For columns, test if each cell is empty and multiply the column number returned from COLUMN. 4. MAX will return the last filled row or column number by ignoring empty cells multiplied by 0.

Uploaded by

Saddam Mulla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views155 pages

Excel Tricks Learned

1. Use the MAX function with an array of row or column numbers multiplied by a logical test to determine if the cell is empty. 2. For rows, test if each cell is empty using ISBLANK and multiply the row number. 3. For columns, test if each cell is empty and multiply the column number returned from COLUMN. 4. MAX will return the last filled row or column number by ignoring empty cells multiplied by 0.

Uploaded by

Saddam Mulla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 155

Vic Mackie

Danny Sofer

Curtis Lemanski
Jon Kavanaugh
Content Page
Topic
1 #REF! Go 22
2 #REF! Go 23
3 Formula to Count like being Autofiltered Go 24
4 #REF! Go 25
5 #REF! Go 26
6 #REF! Go 27
7 #REF! Go 28
8 #REF! Go EE 29
9 #REF! Go 30
10 #REF! Go 31
11 #REF! Go 32
12 #REF! Go 33
13 #REF! Go 34
14 #REF! Go 35
15 #REF! Go 36
16 #REF! Go 37
17 #REF! Go 38
18 #REF! Go 39
19 #REF! Go 40
20 #REF! Go 41
21 #REF! Go 42
N
New

#REF! Go 43
#REF! Go 44
#REF! Go 45
#REF! Go 46
#REF! Go 47
#REF! Go 48
#REF! Go 49
#REF! Go 50
#REF! Go 51
#REF! Go 52
#REF! Go 53
#REF! Go 54
#REF! Go 55
#REF! Go 56
#REF! Go 57
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
#REF! Go
EE
Explanation Added

#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 N

#REF! Go N
<-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 named "Ref".

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 & the cell we are looking for.

=ADDRESS(MATCH(B5,Ref!A1:A15,0),1)
The ADDRESS formula helps us return a cell reference by providing the row number & column number.
row_num is obtained by using the MATCH formula & column number is "1", referring to Column A.
MATCH formula uses "Curtis Lemanski" as a "lookup_value" to find in "lookup_array", Ref!A1:A15. It looks for an exact ma

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.
ell we are looking for.

:A15. It looks for an exact match by indicating "0" & returns the row number.
<-back
Return Unique Values in a List
From a list of duplicate names, it will only pick it once.

Fruits Original Tweak


Apple Apple
Apple Apple Orange
Orange Orange Pear
Pear Pear Mango
Orange Mango 0
Mango 0 #N/A
#N/A

Tweak is customised to my liking. I don't see the need to start 1 cell empty before applying the formula.
In cell C6, the COUNTIF formula starts by only picking the range $E$5:E5. The criteria is the List & so it looks the whole list f
The MATCH formula finds "0" in my results & return row "1" because that's the 1st "0" that appeared.
In Cell C7, the formula of COUNTIF expanded to $E$5:E6. Now it picks up "Tweak" & "Apple". The results will then return {
appeared in rows 1 & 2.
The MATCH formula finds "0" again & returns row 3 this time because the 3rd one in the result is "0".
It goes on until the results for the COUNTIF returns "1" for all & it cannot find a "0". This will then return #N/A.

Source: http://www.exceltip.com/st/Retrieving_Unique_Values_From_A_List/805.html
o it looks the whole list for "Tweak" & it all returns "0".

results will then return {1;1;0;0;0;0;0} because "Apple"

return #N/A.
<-back
Formula to Count like being Autofiltered Solution by JosephP

Selection Database

Age Group Count Cell Link Age Group Occupation Interest


20 - 24 2 ✘ 1 35 - 39 Doctor Music
25 - 29 2 ✘ 1 35 - 39 Accountant Sports
30 - 34 2 ✘ 1 20 - 24 Lawyer Sports
35 - 39 4 ✘ 1 30 - 34 Lawyer Sports
25 - 29 Doctor Movies
Occupation Count 35 - 39 Accountant Music
Doctor 4 ✘ 1 20 - 24 Doctor Movies
Lawyer 3 ✘ 1 25 - 29 Lawyer Sports
Police 1 ✘ 1 30 - 34 Police Movies
Accountant 2 ✘ 1 35 - 39 Doctor Sports

Interest Count
Sports 5 ✘ 1
Music 2 ✘ 1
Movies 3 ✘ 1
Explanation for F3

1st 1st 2nd 2nd


MATCH ISNUMBER MATCH ISNUMBER
($J$3:$J$12=E3) 1 or 0 Formula Formula 1 or 0 Formula Formula 1 or 0
0 0 1 1 1 2 1 1
0 0 4 1 1 1 1 1
1 1 2 1 1 1 1 1
0 0 2 1 1 1 1 1
0 0 1 1 1 3 1 1
0 0 4 1 1 2 1 1
1 1 1 1 1 3 1 1
0 0 2 1 1 1 1 1
0 0 3 1 1 3 1 1
0 0 1 1 1 1 1 1

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

2
<-back
Return Multiple values for same criteria
From a list of duplicate names, it will only pick it once.

Fruits Price Fruits Price 1 Price 2 Price 3 Price 4


Apple $0.50 Apple $0.50 $0.80 $0.75 #VALUE!
Apple $0.80 Orange $1.00 $0.90 #VALUE! #VALUE!
Orange $1.00 Pear $0.75 #VALUE! #VALUE! #VALUE!
Pear $0.75 Mango $3.00 #VALUE! #VALUE! #VALUE!
Orange $0.90 #N/A #N/A #N/A #N/A #N/A
Mango $3.00
Apple $0.75

$E6=$B$6:$B$12
This returns TRUE & FALSE for the range of B6:B12. {TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;TRUE}
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 {0;1;2;3;4;5;6}
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;"";"";"";"";7}
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-excel/
up-in-excel/
<-back
Sort Unique Values in separate list

Sorted Unique List Excelisfun


nicole Alan http://www.youtube.com/watch?v=IZLAzIYfMDU&list=PLA
Ben Ben
Alan nicole
Rachel Phoebe
Alan Rachel
Phoebe
h?v=IZLAzIYfMDU&list=PLA21AB17448044814
<-back
Find Last Filled Row/Column

13 13 13 {=MAX((A5:A20<>"")*ROW(A5:A20))}
array formula that will work for texts or numbers.
a (A5:A20<>"")
this will return a bunch of TRUEs when cell is not empty & FALSEs whe
{FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALS
ROW(A5:A20))
b the ROW formula will return the row number of the range stated.
{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 you multiply them togeth
c {0;6;0;0;0;10;0;0;13;0;0;0;0;0;0;0}
MAX then takes the highest number of the lot.

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

=LOOKUP(2,1/(A5:A20<>""),ROW(A5:A20))
using the LOOKUP again, but works for both numbers & text
A5:A20<>""
this logical test of whether the range are blanks will give TRUEs & FALS
{FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALS
1/(A5:A20<>"")
so again, since TRUEs are 1 & FALSEs are 0, 1 divided by these will give
{#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;1;#DIV/0!;#DIV/0!;1;#DIV/0!;#DIV
my lookup_value is "2", so since the LOOKUP cannot find an exact mat
and using ROW(A5:A20) in the result_vector will give the row number
s not empty & FALSEs when they are empty
E;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

er of the range stated.

f you multiply them together, you'll get

he last row where the text is. It won't work for numbers
zzz". There will not be such a word, so what the LOOKUP
to return the last value found in the lookup_vector (A5:A20),

l then return the row number of "c". If there are texts

numbers & text

anks will give TRUEs & FALSEs


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

1 divided by these will give a bunch of 1s (1/1=1) & #DIV/0 (1/0=error)


0!;#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}
P cannot find an exact match, it returns the last number found
r will give the row number of the last number found.
<-back
Word Count

Total number of words


This is to count words in Excel Pretty cool stuff 13

To find out how many words the


spaces. Add 1 to it & you have th

Hard to imagine TRIM(A3:G12)


To play safe, TRIM the range A3:H
the end ,or more than 1 space in

LEN(TRIM(A3:G12)
this will find the length of charac
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;31,0,0

SUBSTITUTE(TRIM(A3:G12)," ",""
To find the number of spaces exi
unnecessary spaces.

LEN(SUBSTITUTE(TRIM(A3:G12),"
i then find the length of the char
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;25,0,0

LEN(TRIM(A3:G12))
as I mentioned, we need to add 1
{1,1,1,1,1,1,1;1,1,1,1,1,1,1;7,1,1,1

As you can see above, there's a s


(TRIM(A3:G12)<>"")
so we use another array of logica
{FALSE,FALSE,FALSE,FALSE,FALSE

(LEN(TRIM(A3:G12))-LEN(SUBSTI
As Excel treats TRUEs as 1s & FAL
{0,0,0,0,0,0,0;0,0,0,0,0,0,0;7,0,0,0

SUMPRODUCT(
the SUMPRODUCT simply sums t
Total number of words

To find out how many words there are, simply find out how many spaces there are & add 1 to it. For eg. "I love Excel" has 2
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 space before the start, space at
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,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,

SUBSTITUTE(TRIM(A3:G12)," ","")
To find the number of spaces existing in the range, you can substitute spaces with blanks. Again, i use TRIM to get rid of
unnecessary spaces.

LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))
i then find the length of the characters between A3:H20 again, but this time without spaces.
{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,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,

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 spaces we have.
{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,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}

As you can see above, there's a slight problem. Cells that are empty now all have a value of 1 because of the 1 I added.
(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,FALSE;TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FA

(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 are going to be multipled by 1s & 0s
{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,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}

SUMPRODUCT((LEN(TRIM(A3:G12))-LEN(SUBSTITUTE(TRIM(A3:G12)," ",""))+1)*(TRIM(A3:G12)<>""))
the SUMPRODUCT simply sums the numbers up & returns 13.
or eg. "I love Excel" has 2

the start, space at

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

use TRIM to get rid of

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

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

use of the 1 I added.

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

e multipled by 1s & 0s
0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0}
SE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;TRUE,FALSE,
E,FALSE,FALSE,FALSE;TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FA
ALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}
<-back
Frequency (Count Unique Values)
Data Category Counts Definition http://www.youtube.com/watch?v
10 10 1 <=10
11 20 4 11 to 20
12 30 0 21 to 30
14 40 0 31 to 40
18 50 2 41 to 50
44 60 1 51 to 60
49 70 3 61 to 70
56 80 0 71 to 80
61 90 2 81 to 90
66 100 1 91 to 100
70 1 >100
83
84
93
101

Name Data Duplicates CountUnique CountUniqueB


A 1 1 9 3
B 2 0
B 2 2
A 3 0
A 3 2
C 4 1
B 5 4
B 5 0
C 5 0
A 5 0
A 6 1
C 7 0
B 7 2
C 8 1
A 9 1

Name CountUniqueWithBlanks How this formula works:


A 3 =SUMPRODUCT((A40:A54<>"")/CO
first select this portion in the formu
B don’t need negation cos it's TRUEs/FALSEs divided A40:A54<>""
you don't want to count blanks as a
A to blanks
{TRUE;TRUE;FALSE;TRUE;TRUE;FAL
A so A40 is not. A41 is not. A42 is a b

B not sure if you know 1/0 in Excel gi


B formula bar & press F9 to see:
A40:A54
{"A";"B";0;"A";"A";0;"B";"B";0;"A";

so the A40:A54&"" prevents that. i


A40:A54&""
{TRUE;TRUE;FALSE;TRUE;TRUE;FAL
so A40 is not. A41 is not. A42 is a b

not sure if you know 1/0 in Excel gi


formula bar & press F9 to see:
A40:A54
{"A";"B";0;"A";"A";0;"B";"B";0;"A";
A
A so the A40:A54&"" prevents that. i
A40:A54&""
C {"A";"B";"";"A";"A";"";"B";"B";"";"A
B
C now select this portion & press F9
COUNTIF(A40:A54,A40:A54&"")
A it will give you multiple results like
{6;4;3;6;6;3;4;4;3;6;6;2;4;2;6}
what it does is to count how many
it then counts how many times A41
Name CountUniqueWithBlanks&Wildcard counts how many times A42 appea
A #N/A and so on.
B
so you have the 1st part of TRUEs &
{TRUE;TRUE;FALSE;TRUE;TRUE;FAL
1 divided by:
*A {6;4;3;6;6;3;4;4;3;6;6;2;4;2;6}
so that's 1/6, 1/4, 0/3, 1/6... and so
that gives you a fraction of each ce
B (A40:A54<>"")/COUNTIF(A40:A54,A
B {0.166666666666667;0.25;0;0.166
166666666666667}
so that's actually telling you A41 is
1 A42 is 1/4 of how many times "B" a
A A43 is 0. 
C and so on...
B as the above are multiple array resu
C 4 "B"s, that is 1/4 + 1/4 + 1/4 + 1/4
A

Name Vote Criteria


Sioux Yes Yes 4
Sue No
Chin Yes
Swade Yes
Martha Yes
Luong No
Sue No
Sioux Yes

Other ways of obtaining no of unique items with condition

Code Items Code Unique Items


111 X 111 2 #N/A 1
111 X
111 Y
222 X
222 Z
222 Z
333 X
333 Y
333 Z
w.youtube.com/watch?v=uUrI8hoj8BA&feature=plcp

ormula works:
DUCT((A40:A54<>"")/COUNTIF(A40:A54,A40:A54&""))
this portion in the formula bar & press F9 to calculate
>""
want to count blanks as a unique value. so the above will give you a bunch of TRUEs & FALSEs on whether those cells does not equal

UE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}
not. A41 is not. A42 is a blank. and so on
you know 1/0 in Excel gives you an error #DIV/0. and if you have a blank cell, excel returns a 0. you can try highlighting this in the
ar & press F9 to see:

;"A";"A";0;"B";"B";0;"A";"A";"C";"B";"C";"A"}

:A54&"" prevents that. it makes those zeroes become blanks. try highlighting this portion & press F9
""
UE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}
not. A41 is not. A42 is a blank. and so on

you know 1/0 in Excel gives you an error #DIV/0. and if you have a blank cell, excel returns a 0. you can try highlighting this in the
ar & press F9 to see:

;"A";"A";0;"B";"B";0;"A";"A";"C";"B";"C";"A"}

:A54&"" prevents that. it makes those zeroes become blanks. try highlighting this portion & press F9
""
";"A";"A";"";"B";"B";"";"A";"A";"C";"B";"C";"A"}

t this portion & press F9


A40:A54,A40:A54&"")
you multiple results like this (15 results to be exact)
3;4;4;3;6;6;2;4;2;6}
es is to count how many times A40 appeared in A40:A54. that will give you 6. cause "A" appeared 6 times.
unts how many times A41 appeared in A40:A54. that will give you 4. cause "B" appeared 4 times.
w many times A42 appeared in A40:A54. that will give you 3. cause "" appeared 3 times.

e the 1st part of TRUEs & FALSEs (which Excel sees as 1 & 0) divided by the 2nd part of how many times each cell appears.
UE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}
:
3;4;4;3;6;6;2;4;2;6}
/6, 1/4, 0/3, 1/6... and so on
you a fraction of each cells. try selecting this section & press F9
>"")/COUNTIF(A40:A54,A40:A54&"")
666666667;0.25;0;0.166666666666667;0.166666666666667;0;0.25;0.25;0;0.166666666666667;0.166666666666667;0.5;0.25;0.5;0.
6666667}
ctually telling you A41 is 0.167 (1/6) of how the total times "A" appeared. 
of how many times "B" appeared

..

ve are multiple array results of 1/6, 1/4, zeroes, 1, etc, you need a function to add them up. that is the SUMPRODUCT. so if you have
t is 1/4 + 1/4 + 1/4 + 1/4. "A", "B" & "C" is a total of 3 unique values. 
unch of TRUEs & FALSEs on whether those cells does not equal

;TRUE;TRUE}

ank cell, excel returns a 0. you can try highlighting this in the

hlighting this portion & press F9


;TRUE;TRUE}

ank cell, excel returns a 0. you can try highlighting this in the

hlighting this portion & press F9

e you 6. cause "A" appeared 6 times.


ause "B" appeared 4 times.
appeared 3 times.

by the 2nd part of how many times each cell appears.


;TRUE;TRUE}

0.25;0;0.166666666666667;0.166666666666667;0.5;0.25;0.5;0.

red. 

nction to add them up. that is the SUMPRODUCT. so if you have


 
<-back
Count Unique Values With Autofilter

Account Names 5 We need to create set of 1s & 0s to make sure filtered & bla
a SUBTOTAL with function number 3 works like this:
b =SUBTOTAL(3,A5:A15)
c it will count how many non-blank cells exist in A5:A15. what
e depending on whether the particular cell is filtered or blank
g SUBTOTAL(3,A5)
a SUBTOTAL(3,A6)
e ...all the way to SUBTOTAL(3,A15), but inside a single cell.

to implement such a formula, i need the range to be a dynam


inside the OFFSET, but we're just going to use 2 of them.

=OFFSET(reference,rows,cols,[height],[width])
reference
this is the anchor point. so i placed it in A5

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

since we want it to be looking at A5, then A6, then A7, & so


comes in now. the ROW formula gives you the row number,
=ROW(A5)
so the above will return 5. 

to put in a range, it will become an array. to see the results s


=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, you simply have to minu
=ROW(A5:A15)-ROW(A5)
{0;1;2;3;4;5;6;7;8;9;10}

=SUBTOTAL(3,OFFSET(A5,ROW(A5:A15)-ROW(A5),))
so if you select the SUBTOTAL & OFFSET formula above & pr
{1;1;1;1;1;1;1;0;0;0;0}
this is when nothing is filtered. The last 4 zeroes are becaus

it then combines with the FREQUENCY formula IF the above


to make sure filtered & blank rows are not calculated. SUBTOTAL works great with filters. a simple
r 3 works like this:

k cells exist in A5:A15. what i want is a series of numbers that will give me 1 count or 0 count,
cular cell is filtered or blank. that means i actually want

5), but inside a single cell.

eed the range to be a dynamic one; using the OFFSET formula. there are 5 arguments you can input
going to use 2 of them.

eight],[width])

it away from the anchor point. 

ng 0 rows & 0 columns away from A5. so this is exactly like putting:

A5, then A6, then A7, & so on... the "rows" is where we'll put numbers of 0 to 10. the ROW formula
gives you the row number, regardless of what column it's in,

an array. to see the results select the formula & press F9

10, you simply have to minus whatever row number you start in.

A5:A15)-ROW(A5),))
OFFSET formula above & press F9, you should be seeing:

The last 4 zeroes are because the data are blanks.

UENCY formula IF the above shows as 1 (non-filtered or non-blanks)


<-back
SUMPRODUCT to work with Autofilter
Need to Filter
on range and get sumproduct total here SUMPRODUCT(D8:D19,E8:E19)
Price Units a simple SUMPRODUCT like the above would simply give yo
£65,600 So that gives you 65,600.

Range 1 Item 1 £6.00 500 hence, we need to create another set of 1s & 0s to make su
Range 1 Item 2 £59.00 100 SUBTOTAL with function number 3 works like this:
Range 1 Item 3 £6.00 800 SUBTOTAL(3,B8:B19)
Range 1 Item 4 £5.00 100 it will count how many non-blank cells exist in B8:B19. wha
Range 1 Item 5 £6.00 500 depending on whether the particular cell is filtered. that m
Range 1 Item 6 £5.00 1,000 SUBTOTAL(3,B8)
Range 2 Item 1 £59.00 500 SUBTOTAL(3,B9)
Range 2 Item 2 £6.00 100 ...all the way to SUBTOTAL(3,B19), but inside a single cell.
Range 2 Item 3 £6.00 800
Range 2 Item 4 £5.00 100 to implement such a formula, i need the range to be a dyna
Range 2 Item 5 £6.00 500 inside the OFFSET, but we're just going to use 2 of them.
Range 2 Item 6 £5.00 1,000
=OFFSET(reference,rows,cols,[height],[width])
reference
this is the anchor point. so i placed it in B8

rows
this is how many rows you want it away from the anchor p
to test it out, try inputting:
=OFFSET(B8,0,0)
it is equivalent to putting
=OFFSET(B8,,)
this means anchor in B8, & moving 0 rows & 0 columns aw
=B8

since we want it to be looking at B8, then B9, then B10, & s


comes in now. the ROW formula gives you the row number
=ROW(B8)
so the above will return 8. 

to put in a range, it will become an array. to see the results


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

SUBTOTAL(3,OFFSET(B8,ROW(B8:B19)-ROW(B8),))
so if you select the SUBTOTAL & OFFSET formula above & p
{1;1;1;1;1;1;1;1;1;1;1;1}
this is when nothing is filtered. after filtering, you should se

what SUMPRODUCT does is to multiply & add these numbe


so you notice that whatever is filtered wont be calculated b
above would simply give you a result of D8*E8 + D9*E9 + ….. And so on

er set of 1s & 0s to make sure filtered rows are not calculated. SUBTOTAL works great with filters. a simple
r 3 works like this:

k cells exist in B8:B19. what i want is a series of numbers that will give me 1 count or 0 count,
cular cell is filtered. that means i actually want

9), but inside a single cell.

eed the range to be a dynamic one; using the OFFSET formula. there are 5 arguments you can input
going to use 2 of them.

eight],[width])

it away from the anchor point. 

ng 0 rows & 0 columns away from B8. so this is exactly like putting:

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

an array. to see the results select the formula & press F9

11, you simply have to minus whatever row number you start in.

8:B19)-ROW(B8),))
OFFSET formula above & press F9, you should be seeing:
fter filtering, you should see a couple of 0s appearing. 

multiply & add these numbers, so this is how it does it:


tered wont be calculated because anything multiplies by 0 is 0. 
<-back
Count Unique Date for Supplier (Non-array)
Date Supplier Mine Supplier Date by Ron Coderre
31-Jul-12 A 7 A Aug_2012 0
1-Aug-12 A 2 logical tests need to d
3-Aug-12 A =(TEXT(A4:A23,"mmm
6-Aug-12 A this will convert A4:A23
8-Aug-12 A the results would be:
9-Aug-12 A {FALSE;TRUE;TRUE;TRU
### A
### B the 2nd logical test is:
### B =(B4:B23=F4)
### C just to check if B4:B23
### B {TRUE;TRUE;TRUE;TRU
### B
### B the next step is to com
### A and we only want to ta
### B twice; once in row 12 &
### B to find the row number
### B =MATCH(A4:A23&B4:B
### C dates are actually seria
3-Sep-12 C to General & you'll see
4-Sep-12 C number of 31-Jul-12 &
& returns 1 (1st value).
returns such an array:
{1;2;3;4;5;6;7;8;9;10;
notice that the 11th va
MATCH returns the 1st

we then need to conve


whenever it repeats. F
above to an incrementa
it'll turn FALSE.
=(ROW(B4:B23)-ROW(
{1;2;3;4;5;6;7;8;9;10;11

so combining the 2 tog


=MATCH(A4:A23&B4:B
{TRUE;TRUE;TRUE;TRU

now that we have the 3


=(TEXT(A4:A23,"mmm
{FALSE;TRUE;TRUE;TRU
Only when 3 logical tes
by 0 is 0.

If I were to then use 1 t


is 1 while 1/FALSE(or 0)
=1/((TEXT(A4:A23,"mm
{#DIV/0!;1;1;1;1;1;1;#D

the COUNT formula wil


formula inside a COUN
formula inside an INDE
the array of values inst
=INDEX(1/((TEXT(A4:A

The final part is simply


=COUNT(INDEX(1/((TE
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 apple-to-apple comparison
the results would be:
{FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE}

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;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

the next step is to combine the range of column A & B to make the values unique to the Date & Supplier
and we only want to take in the 1st value that appear as the unique value. For eg in 17-Aug-12, Supplier "B" appeared
twice; once in row 12 & the other in row 14. we only want to take in row 12 in order not to double-count
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 didn’t know that. But that's a whole long story. Format cells of column A
to General & you'll see what I mean). So if you combine A4&B4, you actually get "41121A"; "41121" being the serial
number of 31-Jul-12 & combining with "A". So the MATCH formula finds "41121A" inside the range of A4:A23&B4:B23
& returns 1 (1st value). it then searches for A5&B5 in the same range & returns 2 (2nd value). it continues &
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) is 9 instead of 11. That is because
MATCH returns the 1st instance of the row it finds. The combination 17-Aug-12 & "B" is already found in the 9th value

we then need to convert the above into TRUEs & FALSEs. TRUE is whenever the value is the 1st instance, FALSE is
whenever it repeats. For this case, only the red value above should be FALSE. To do that, simply compare the
above to an incremental number of 1 to 20. when it reaches the 11th value, it will use the 9 in red above vs 11 &
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;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}

now that we have the 3 logical tests, simply multiply them to get the final outcome of TRUEs & FALSEs.:
=(TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)
{FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}
Only when 3 logical tests turns TRUE will it be TRUE because TRUE is equivalent to 1 & FALSE to 0. Anything multiplied

If I were to then use 1 to divide it by a bunch of TRUEs & FALSEs, it will give me 1s & DIV errors because 1/TRUE(or 1)
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:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1)
{#DIV/0!;1;1;1;1;1;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}

the COUNT formula will count how many of them are numbers, ignoring errors. But if you simply put the above
formula inside a COUNT formula, it would have to be an array formula. To prevent that, put the whole chunk of
formula inside an INDEX formula. By putting in a "0" for the row argument of the INDEX formula, it will give you
the array of values instead of a single value an INDEX formula usually returns.
=INDEX(1/((TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4)+1))

The final part is simply to add the COUNT formula:


=COUNT(INDEX(1/((TEXT(A4:A23,"mmm\_yyyy")=G4)*(B4:B23=F4)*MATCH(A4:A23&B4:B23,A4:A23&B4:B23,0)=(ROW(B4:B23)-ROW(B4
ALSE;FALSE}

LSE;FALSE;FALSE}

ROW(B4)+1)
ALSE;FALSE;FALSE}
23)-ROW(B4)+1))
V/0!;#DIV/0!}

W(B4:B23)-ROW(B4)+1)),0)

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 useful in doing a Text-To-C
rough idea. And I also found the flipping of the Name interesting.
=A4&" "&A4
what the formula does is to use A4, combine it with a space & with cell A
the middle.
JONES/JACK JONES/JACK

there are 3 parts in the above text, separated by the backslash. To make
A good number to use would be double the length of the text in A4. 100

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


so to do the substitution, "JONES/JACK JONES/JACK" will be the text whe
repeat a certain text the number of times you desire. That will give you
"JONES JACK JON

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


the text with 100 spaces in between will be in our 1st argument of the M
you want the 1st part, then put in "1". For the 2nd part, put in the numb
you repeated spaces, multiplied by 2. this will ensure you have selected
texts.
" JACK JONES "

To remove the unnecessary spaces, simply use TRIM. TRIM will remove
between words. Lastly, user PROPER to make sure the first letter is in Ca
=PROPER(TRIM(MID(SUBSTITUTE(A4&" "&A4,"/",REPT(" ",100)),100,100
ly useful in doing a Text-To-Column style using just a formula to copy across. This eg doesn’t do that but gives a
the Name interesting.

e it with a space & with cell A4 again. It creates the below effect & what we have to do is extract everything in

ed by the backslash. To make it easy for us to extract, we can substitute the slashes by a hundred spaces in between.
length of the text in A4. 100 is just a bigger & safer number to use.

ES/JACK" will be the text where it will substitute the 2 "/" with 100 spaces (using the REPT formula). REPT is to
ou desire. That will give you this result:
JACK JONES JACK"

,100)),100,100)
in our 1st argument of the MID formula. The 2nd argument depends on which part of the text do you want. If
he 2nd part, put in the number of times you repeated the spaces. For the 3rd part, put in the number of times
will ensure you have selected a bunch of spaces, along with the text you want, without including the unwanted

"

use TRIM. TRIM will remove spaces before & after the first & last words, and ensure only a single space is in
ke sure the first letter is in Capital letter & the rest in small.
A4,"/",REPT(" ",100)),100,100)))
<-back
Find if Exact Match exist in string of texts

Find "M1"
M10,M1,M120 1 if you simply search for "M1" within the text, you'll notice that anything
M10,M120 0 in a scenario where "M1" is the 1st text to appear, it would be "M1,etc, etc
But we can't do that because if it appears in the last text, it would not cont
so if we want to find an exact match, add in commas in front & behind the
=","&A5&","
that will give us:
,M10,M1,M120,

so we can now search for ",M1," & no matter which position it's in, it will ha
=SEARCH(",M1,",","&A5&",")

lastly, put in ISNUMBER to return whether or not the SEARCH formula cont
=ISNUMBER(SEARCH(",M1,",","&A5&","))
t, you'll notice that anything containing "M1" would be considered. Anything like M10, M120 or EM10.
ppear, it would be "M1,etc, etc". So a safer bet would be to find "M1," instead of just "M1".
the last text, it would not contain a comma behind. Eg. "etc, etc, M1"
commas in front & behind the text

er which position it's in, it will have commas both in front & behind.

or not the SEARCH formula contains a number. If it does, it means ",M1," is found
<-back
Position of the last occurance of certain character

Find last "."


lalala.woooo.com 13 this is especially useful when you need to extract everything before or after the las
ahh.oooh.e.yy 11
=LEN(A5)
first, you can find out how many of such a character are there. To do that, find the
you will get 16 characters

=LEN(SUBSTITUTE(A5,".",""))
then substitute the character (the one we are showing here is ".") with blanks & fin
you will get 14 characters. That means if the text is without the ".", you have 14 ch

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

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

=FIND("*",SUBSTITUTE(A5,".","*",LEN(A5)-LEN(SUBSTITUTE(A5,".","")))
with a special character "*" now, it's much easier to find the position
thing before or after the last occurance of a certain character.

e there. To do that, find the length of the text

here is ".") with blanks & find out the length


hout the ".", you have 14 characters

uch characters (".") are there

allows you to only substitute that particular instance. We can substitute the last instance of "." with some special
d in the last argument, it's the result we obtained above to find the last instance of "."

TUTE(A5,".",""))))
d the position
<-back
COUNTIF to count non-blanks or blanks

Count non-blank text entries


2a Using COUNTIF(B5:B7,"<>") or COUNTA will not consider "" returned by a formula
2 so you can use COUNTIF(B5:B7,">""") for this case. Do note that this only works o
3c

Count blank
1a just an alternative to COUNTBLANK, COUNTIF with "=" does the same, or just ""
1
1c
er "" returned by a formula to be blank
note that this only works on text.

does the same, or just ""


<-back
Return array of results using INDEX

grade 1 grade 2 grade 3 grade 4 A B C


1 A A C B 7 1 1 0
2 C A C B 1 2 1 1
3 B A D C 2 1 1 2
4 C A D C 6 0 3 0
5 B A F D 5 1 1 0
6 B B B F 3 1 1 1
7 F B A F 8 1 0 2
8 F C C A 4 1 0 2

to zoom into the correct row for COUNTIF, you

=MATCH($G5,$A$5:$A$12,0)
this will give you the row position G5 (7) is foun

=INDEX($B$5:$E$12,MATCH($G5,$A$5:$A$12,0
and instead of returning a single value from tha
if you were to select the above above & press F
{"F","B","A","F"}
that's what B11:E11 contains. You can also omi
=INDEX($B$5:$E$12,MATCH($G5,$A$5:$A$12,0
D F
0 2
0 0
0 0
0 1
1 1
1 0
0 1
1 0

ect row for COUNTIF, you can use INDEX with "0" in the column_num to return an array of results

row position G5 (7) is found in A5:A12

MATCH($G5,$A$5:$A$12,0),0)
ing a single value from that row position, we can use "0" in the end to return the results from B11:E11
he above above & press F9 to calculate, you'll get:

ontains. You can also omit zero and the default value is 0
MATCH($G5,$A$5:$A$12,0),)
<-back
Find last value/text

814 814 Value 320 The LOOKUP & VLOOKUP with approximate matc
478 of the values searched, it will return the last value
#N/A #N/A Text c type 9E+10 to get 9 + 10 zeros
880
814 Both 64
a
814
KUP with approximate match will first look for an exact match. In a scenario where lookup value is larger than all
d, it will return the last value
<-back
Round Up Time to next 5 mins

by daddylonglegs
10:02 AM 10:05 AM
8:36 AM 8:40 AM
4:29 PM 4:30 PM
<-back
Rank tie the same and the next + 1

Students Ranking
Name Scores Ranking Alternative
Lola 21% 15 15 To prevent using an array formula in column
Manny 18% 16 16
Frances 15% 17 17 =(B6<=$B$6:$B$27)
Cindy 10% 19 19 The aim here is to count how cells are greate
Tamie 97% 1 1 A list of TRUEs & FALSEs will be returned:
Ben 32% 14 14 {TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;TRUE;T
Smith 86% 5 5 But do note that due to same Scores by 2 or m
Willy 88% 4 4
James 50% 10 10 =COUNTIF($B$6:$B$27,$B$6:$B$27)
Penny 11% 18 18 to find out if the Scores are duplicates, we ca
Lance 34% 13 13 {1;1;1;1;2;1;1;1;1;2;1;1;1;2;2;2;1;1;2;1;1;1}
Adam 90% 3 3 this results means 21% appeared once, 18%,
Emerson 43% 12 12
Rose 69% 7 7 =1/COUNTIF($B$6:$B$27,$B$6:$B$27)
Kathy 69% 7 7 this next part is then to use 1 divided by thos
Jerry 97% 1 1 twice, it would be 1/2 & return 0.5
Wally 59% 8 8 {1;1;1;1;0.5;1;1;1;1;0.5;1;1;1;0.5;0.5;0.5;1;1;0
Donna 78% 6 6 and of course, if there were Scores that appe
Colleen 11% 18 18
Nelly 45% 11 11 =($B$6:$B$27>=B6)*1/COUNTIF($B$6:$B$27
Tom 92% 2 2 and if we multiply both of the 2 above, those
Sam 55% 9 9 {1;0;0;0;0.5;1;1;1;1;0;1;1;1;0.5;0.5;0.5;1;1;0;1
but the end result after adding them up the d

=SUMPRODUCT(($B$6:$B$27>=B6)*1/COUN
the SUMPRODUCT helps us do the summing.
rray formula in column C, you can use the SUMPRODUCT method in column F

unt how cells are greater or equals to B6. that will be the Score ranking.
SEs will be returned:
ALSE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE}
to same Scores by 2 or more people, the ranking is skewed.

27,$B$6:$B$27)
es are duplicates, we can use COUNTIF & the range is the same as the criteria.
;1;1;2;2;2;1;1;2;1;1;1}
% appeared once, 18%, once, 15% once. When it reaches 97% (B10), it actually appears twice, the other one in B21

B$27,$B$6:$B$27)
to use 1 divided by those numbers above. If the Score appeared only once, it'll be 1/1 & return 1. but if it appears
2 & return 0.5
5;1;1;1;0.5;0.5;0.5;1;1;0.5;1;1;1}
e were Scores that appeared thrice, it will take 1/3

1/COUNTIF($B$6:$B$27,$B$6:$B$27)
th of the 2 above, those duplicates will have values less than 1.
1;1;1;0.5;0.5;0.5;1;1;0;1;1;1}
er adding them up the duplicates would always be 1, thus ensuring we do not double count

$6:$B$27>=B6)*1/COUNTIF($B$6:$B$27,$B$6:$B$27))
lps us do the summing.
<-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 Use "+" for either column to have "J
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
or either column to have "Jill", curly brackets for a column to have "Floor" or "Counter"
<-back
Put the "st,nd,rd,th" behind the day

1-Nov-12 1st =DAY(A4)


2-Nov-12 2nd The day formula returns the day of the date
3-Nov-12 3rd
4-Nov-12 4th The LOOKUP formula searches for an exact match of the lookup_
5-Nov-12 5th We could make a lookup_vector of 1 to 31 & the results vector w
6-Nov-12 6th But there are some numbers in between we can actually skip; fro
7-Nov-12 7th So these are the only numbers we need:
8-Nov-12 8th {1,2,3,4,21,22,23,24,31}
9-Nov-12 9th and the respective texts it returns:
10-Nov-12 10th {"st","nd","rd","th","st","nd","rd","th","st"}
11-Nov-12 11th
12-Nov-12 12th so when the day is say 8, it is unable to find an exact match in th
13-Nov-12 13th will then return the text "th".
14-Nov-12 14th
15-Nov-12 15th Combined with the ampersand key, it combines the day of the d
16-Nov-12 16th
17-Nov-12 17th
18-Nov-12 18th
19-Nov-12 19th
20-Nov-12 20th
of the date

or an exact match of the lookup_value in the lookup_vector first. If it can't find one, it returns the last value closest to it
of 1 to 31 & the results vector with the text of "st" for 1st, "nd" for 2nd, "rd" for 3rd & so on
between we can actually skip; from 4th to 20th are all ending with "th". The same for 24th to 30th.

able to find an exact match in the lookup_vector. It then goes back to the last value closest to it & picks "4". The result_vector

ey, it combines the day of the date & the text


st value closest to it

cks "4". The result_vector


<-back
Sum 1st 12 non-blank cells

653 1 23 44 55 66 77 88
438 0 10 55 56 54 33 25 47
254 78

=ISNUMBER(C4:U4)
To find out if C4:U4 contains numbers, we can use ISNUMBER. That will give us a bunch of TRUEs & FALSEs
{TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FAL

=IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1)
When they are indeed numbers, then return the column number they are in. COLUMN(C4:U4) would have g
{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 COLUMN(C4) to return:
{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 up as:
{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:U4)))
We need to know the 12th smallest column number to decide where our SUM should stop. Hence, we can u
But in a scenario where there could be a possibility of less than 12 numbers available, we can use COUNT to c
count of numbers, depending which is smaller. So in our case here, we have 13 numbers in C4:U4. We woul
number is 16, where the last 44 resides.

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

=C4:INDEX(C4:U4,SMALL(IF(ISNUMBER(C4:U4),COLUMN(C4:U4)-COLUMN(C4)+1),MIN(12,COUNT(C4:U4))))
But here's a cool trick. If you put a cell reference in front of it with a colon & then slot in the INDEX formula,
=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)+1),MIN(12,COUNT(C4:U
Lastly, just put a SUM to sum up C4:R4. press CTRL + SHIFT + ENTER to confirm as this is an array formula
24 86 67 78 44 10
26 5 99 28 55 93
55 28 93

us a bunch of TRUEs & FALSEs


UE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE}

COLUMN(C4:U4) would have given us:

using COLUMN(C4) to return:

ll show up as:

UNT(C4:U4)))
M should stop. Hence, we can use the SMALL formula where the above formula gives us the array of values
vailable, we can use COUNT to count how many numbers there are. We then take the MIN of both values; 12 or the
13 numbers in C4:U4. We would take 12 since 12 is smaller than 13. Therefore, the 12th smallest value of the column

1),MIN(12,COUNT(C4:U4))))
ch is in cell R4.

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

MN(C4)+1),MIN(12,COUNT(C4:U4)))))
m as this is an array formula
<-back
Sum unique -ve & non-NA

-100 -290 We need to do 3 things here; identify which are numbers (non-errors), which
-100
-100 =ISNUMBER(A4:A17)
#N/A this will let us know which are numbers. Those with numbers will be TRUE &
#N/A {TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TR
#N/A
120 =A4:A17<0
120 All those that are lesser than 0 would turn TRUE, otherwise FALSE. Note that
120 {TRUE;TRUE;TRUE;#N/A;#N/A;#N/A;FALSE;FALSE;FALSE;FALSE;TRUE;TRUE;FA
120
-190 =IF(ISNUMBER(A4:A17),IF(A4:A17<0,A4:A17/COUNTIF(A4:A17,A4:A17)))
-190 once we put the logical tests this way, it eliminates the N/As in the first logica
200 it then does this:
200 A4:A17/COUNTIF(A4:A17,A4:A17)
The COUNTIF will count how many times each row appears.
{3;3;3;3;3;3;4;4;4;4;2;2;2;2}
the above means the value of A4 appeared 3 times. So did A5:A9. Value in A
by the number of times each row appears, summing them up will ensure we d
{-33.3333333333333;-33.3333333333333;-33.3333333333333;FALSE;FALSE;F
the value "-100" in A4 appeared 3 times, so it took -100/3 & returns "-33.3333
twice. Hence, -190/2 & returns "-95".

=SUM(IF(ISNUMBER(A4:A17),IF(A4:A17<0,A4:A17/COUNTIF(A4:A17,A4:A17))
By summing up the numbers above, it will return what we need.
are numbers (non-errors), which are negative values & add them up just once if it repeats.

ose with numbers will be TRUE & those with errors will flag out as FALSE
;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}

RUE, otherwise FALSE. Note that this logical test must be after the ISNUMBER. Otherwise, N/As will appear.
FALSE;FALSE;FALSE;TRUE;TRUE;FALSE;FALSE}

7/COUNTIF(A4:A17,A4:A17)))
minates the N/As in the first logical test first before proceeding to whether A4:A17 is lesser than 0. when both are TRUE,

ch row appears.

3 times. So did A5:A9. Value in A10 appeared 4 times, & so on. So if we were to take the values in A4:A17 & divide it
umming them up will ensure we don’t double count. So if you select everything inside the SUM & press F9:
33.3333333333333;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;-95;-95;FALSE;FALSE}
it took -100/3 & returns "-33.3333….". The 4th value is FALSE because it's N/A. The other value is "-190", which appeared

A4:A17/COUNTIF(A4:A17,A4:A17))))
eturn what we need.
when both are TRUE,

A4:A17 & divide it

190", which appeared


<-back
Convert yyyymmddhhmm to proper format

custom custom
Date by daddylonglegs with "A"0 with \A0 Backslash will treat the next single text a
201206010053 1-Jun-12 00:53 A10 A10
will treat the next single text as if in double quotes
<-back
Non-array Way of Min with Condition
Added: Dec 2013
Name Cost Name Array Mine Marcelo Branco T. Valko Jeeped
a 89 a 66 Err:504 66 66 Err:504
v 26 1 3 4 1 2
a 73
g 33 My Method
a 66 =(A5:A9="a")
I used a logical test to find out if A5:A9 is equals to "a". It will retu
{TRUE;FALSE;TRUE;FALSE;TRUE}

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

=INDEX((A5:A9="a")*(B5:B9),)
to make it a non-array formula, I store it inside an INDEX formula.
=INDEX((A5:A9="a")*(B5:B9),0)
And this will return you a series of values instead of just a single va

=COUNTIF(A5:A9,"<>a")+1
however, if I were to look for the minimum value in {89;0;73;0;66}
not have "a" in A5:A9. What I want here is actually the 3rd smalle
how many cells are NOT equals to "a" in A5:A9. those will be the c

=SMALL(INDEX((A5:A9="a")*(B5:B9),),COUNTIF(A5:A9,"<>a")+1
With that, I can use the SMALL formula to find out the 3rd smalles

Marcelo Branco's method


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

=9.99E+307*(A5:A9<>D5)
9.99E+307 is the largest number Excel can store. This is multiplied
{0;9.99E+307;0;9.99E+307;0}

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

=MIN((A5:A9=D5)*B5:B9+ 9.99E+307*(A5:A9<>D5))
With that, you can then find the minimum of all the values & get "

=SUMPRODUCT(MIN((A5:A9=D5)*B5:B9+ 9.99E+307*(A5:A9<>D5
the number though, is obtained through an array & needs to be w
T. Valko's method
=1E+100*(A5:A9<>D5)
1E+100 is 1 plus a hundred zeroes. Like Marcelo Branco's method
to multiply only when A5:A9 is NOT equals to "a"
{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<>D5)+B5:B9))
The SUMPRODUCT & the MIN has the same effect as Marcelo's

Explanation added: Dec 2013


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

daddylongleg's method
=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 M
It cannot work because the results for the FALSEs would give you a
zero if any values in A4:A13 is not "abc".
You can still do the same logical test multiplied by the values in B4
=(A4:A13=E4)*B4:B13
to store these values so that they won't become an array is to use
=INDEX((A4:A13=E4)*B4:B13,0)
I have 4 values in A4:A13 that are "abc".  Hence, the smallest num
array obtained from INDEX((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.
Added: Dec 2013
daddylonglegs
Err:504
3 Speed, using Charles Kyd's Calculation Timer - Fastest to Slowest (1-5)

equals to "a". It will return a bunch of TRUEs & FALSEs

if I were to multiply them by the values in B5:B9, I would get the values just for those whose Names in A5:A9 are "a"

inside an INDEX formula. By not putting any values in the row_num portion, it is equivalent to putting a 0:

instead of just a single value

um value in {89;0;73;0;66}, it would return me 0. that's not what I want. 0 appeared because those values did
is actually the 3rd smallest number, since there are 2 zeroes. 66 is what I want to return. So I can use COUNTIF to count
A5:A9. those will be the count of A6 & A8, equivalent to the count of zeroes. Then I add +1 to say I want the 3rd smallest

OUNTIF(A5:A9,"<>a")+1)
o find out the 3rd smallest of the array.

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

n store. This is multiplied by a different logical test; when A5:A9 is NOT equals to "a".

a" in A5:A9 will be its original value. Every other cells will be having the biggest number Excel can hold. So:

A5:A9<>D5))
m of all the values & get "66"

+ 9.99E+307*(A5:A9<>D5)))
an array & needs to be within the SUMPRODUCT to make it non-array
Marcelo Branco's method, this is also using a huge number multiplied by the same 2nd logical test Marcelo did;

D5)+B5:B9))
me effect as Marcelo's

ce/wiki/office_2013_release-excel/minif-maxif-and-modeif-with-standard-formulas/144a2f30-31ef-408e-86c3-f1443d9ac1fd

COUNTIF(A4:A13,E4))
be simply to change the MAX to MIN in the SUMPRODUCT formula earlier.
e FALSEs would give you a bunch of zeroes and the MIN would definitely return

tiplied by the values in B4:B13 like this:

become an array is to use INDEX with 0 as the row_num:

Hence, the smallest number for "abc" is actually the 4th largest number in my
)*B4:B13,0)

red, I can use COUNTIF:

the nth largest number.


NTIF to count
e 3rd smallest
6c3-f1443d9ac1fd
<-back
Non-array Way of Max with Condition
tigeravatar
xyz 50 abc 740 Explanation added: Jul
xyz 270 The formula is basically
xyz 280 MAX with IF
abc 740 740 =SUMPRODUCT(MAX((
xyz 1000 This formula to substitu
abc 470 =A4:A13=E4
abc 120 That will return TRUEs &
xyz 410 {FALSE;FALSE;FALSE;TR
xyz 250 to return the numbers w
abc 170 =(A4:A13=E4)*B4:B13
The results will show B4
{0;0;0;740;0;470;120;0;
By putting a MAX formu
 =MAX((A4:A13=E4)*B4
But the above is an arra
can add in the SUMPRO

=LARGE(INDEX((A4:A13
You might think that th
It cannot work because
zero if any values in A4:
You can still do the sam
=(A4:A13=E4)*B4:B13
to store these values so
=INDEX((A4:A13=E4)*B
I have 4 values in A4:A1
array obtained from 
{0;0;0;740;0;470;120;0;
To find out how many ti
=COUNTIF(A4:A13,E4)
To end it, use the LARG
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 is "abc" by doing:
=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 to confirm it.  To prevent that, you
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 SUMPRODUCT formula earlier.
It cannot work because the results for the FALSEs would give you a bunch of zeroes and the MIN would definitely return
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 row_num:
=INDEX((A4:A13=E4)*B4:B13,0)
I have 4 values in A4:A13 that are "abc".  Hence, the smallest number for "abc" is actually the 4th largest number in my
array obtained from INDEX((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.
To prevent that, you

formula earlier.
ould definitely return

rgest number in my
<-back
Arrange in 1 column, by row then by column

Top Rated 2nd Rated


White Coppice Becky Lou White Coppice The pattern here is that we must first pick up the
Summer Dream Zero Game Becky Lou If you noticed, the rows is to increase by 1 after
Face The Problem Rowe Park Summer Dream
Communicator Area Fifty One Zero Game =(ROWS(D$5:D5)+1)/2
Face The Problem ROWS formula will count how rows are there in
Rowe Park row, it's going to increase by 1 when the formula
Communicator would be (2+1)/2 & return me 1.5. INDEX will on
Area Fifty One 2. following that would be (4+1)/2, returning 2.5

=MOD(ROWS(D$5:D5)-1,2)+1
The MOD formula returns the remainder that ca
=MOD(3,2)
3 can be divided by 2 & a remaining of 1 cannot
=MOD(4,2)
4 can be wholly divided by 2 & hence return 0 as
We are going to use ROWS again & lock the row
0. We then add +1 behind to obtain 1. The reas
add +1 for it to become 2.

=INDEX(A$5:B$9,(ROWS(D$5:D5)+1)/2,MOD(RO
And then, we can add in the INDEX formula & ch
column_num.
at we must first pick up the 1st row, 1st column. Then followed by 1st row, 2nd column. And then 2, 1. 2, 2. 3, 1. 3, 2.
ws is to increase by 1 after every 2 rows & the column is to switch between 1 & 2.

unt how rows are there in the range stated. I stated D$5:D5, so there is only 1 row in total. But because I locked the
ease by 1 when the formula is copied down. I then added 1 because I want the first cell to be 2/2 to get 1. The 2nd row
eturn me 1.5. INDEX will only take the integer & hence take only 1, ignoring 0.5. the 3rd row would be (3+1)/2 & returns
uld be (4+1)/2, returning 2.5. Notice that I'm now getting an increment of 1 after 2 rows.

urns the remainder that cannot be divisible by the divisor stated. An eg:

& a remaining of 1 cannot be divisible to return a whole number. Hence, it returns 1 as the remainder. if I were to put:

ed by 2 & hence return 0 as the remainder.


ROWS again & lock the row to get 1 for the first cell. We then minus 1 to obtain 0. so it becomes MOD(1-1,2) & return
ehind to obtain 1. The reason for deducting & adding is for the next row. It becomes MOD(2-1,2) & returns 1. We then

WS(D$5:D5)+1)/2,MOD(ROWS(D$5:D5)-1,2)+1)
d in the INDEX formula & choose A5:B9 as the array, while the other 2 formula combinations give us the row_num &
<-back
List non-blank fields without array

Peter 0 Solution by Marcol


Paul John
Tracy 0
0
John Darcy As you can see here in A4:A13, there are some blank cells in betwe
0 C4:C13
Abigail James
Darcy Those of us who knows array formulas can probably easily do a fo
especially if you’re dealing with a huge file. So here’s a method by
James
First off, we can see that what we need is to return rows 4, 5, 6, 8,

So let’s do a formula that returns the row number; the ROW formu
=ROW(A4)

It will return me the row number of A4, which is “4”. But if you lis
=ROW($A$4:$A$13)
{4;5;6;7;8;9;10;11;12;13}
As you can see, it creates a list of numbers from Row 4 to Row 13.
=ROW($A$4:$A$13)

Since row 7, 9 & 12 are blanks, we have to make sure these row nu
out if the cells are blanks:
=$A$4:$A$13<>""

Again, if you click inside the formula bar & press F9 to calculate, yo
FALSE means it is a blank:
{TRUE;TRUE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE}
Now, TRUE in Excel is actually equivalent to the value “1” & FALSE
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 eg, is not a blank. The lo


course “4”, so the multiplication will be “1*4”, & returning “4”. Th
value of it is “0”. Whatever the row number is, “0” multiplies by a

Cell Logical Test Equivalent to:


A4 1 1
A5 1 1
A6 1 1
A7 0 0
A8 1 1
A9 0 0
A10 1 1
A11 1 1
A12 0 0
A13 1 1

If we were to rank the numbers after the multiplication, “0” would


value on my list should be the 4th smallest row number, and the s
COUNTBLANK to count how many “0”s I have.
=COUNTBLANK($A$4:$A$13)

That will give me a result of “3”. My list will be incremental by 1 a


to add incremental value of 1 as it goes down (i.e. 4th smallest, 5t
=COUNTBLANK($A$2:$A$11)+ROWS($A$4:$A4)

To find the nth smallest number, we can use the SMALL formula.
be our COUNTBLANK & ROWS formula:
=SMALL(($A$4:$A$13<>"")*ROW($A$4:$A$13),COUNTBLANK($A$

This formula above is good enough for an array formula. If you pr


referring to Row 4. Copy the formula down & you should see it sk

As you can see, we have been pressing F9 inside the formula bar t
But we actually can park this array of values in the INDEX formula
=INDEX(array, row_num, [column_num])
We normally fill in the “row_num” or “column_num” as a number
we were to put in “0” in either of them, it will give us all the values
=($A$4:$A$13<>"")*ROW($A$4:$A$13)

We can then put this formula inside the INDEX formula & put a “0
=INDEX(($A$4:$A$13<>"")*ROW($A$4:$A$13),0)

And applying this back in the SMALL formula, you don’t have to pr
=SMALL(INDEX(($A$4:$A$13<>"")*ROW($A$4:$A$13),0),COUNTB
We still have some loose ends to finish, but the toughest part is ov

So column C should be showing the text in row 4 instead of the jus


row 11, it is looking for the 11th smallest, but we only have 10 num
INDEX formula for us to return the row of the array we state. The
=INDEX($A$1:$A$11,SMALL(INDEX(($A$4:$A$13<>"")*ROW($A$4
This is just to say from A1:A11, pick out the 4th row. Copy down &

Now, to handle the errors, we have find out how many cells are no
formulas that return blank cells. So we use this instead:
=COUNTIF($A$4:$A$13,">""")

This will return “7” as we have 7 non-blank cells. Our 8th value is
non-blank cells, return blank. Otherwise, do the formula. To get t
=ROWS($A$4:$A4)>COUNTIF($A$4:$A$13,">""")

This is a logical test that will return TRUE or FALSE. Since ROWS($
blank in the TRUE statement & the long formula we created, in the
“8” will be greater than 7. Using IF:
=IF(ROWS($A$4:$A4)>COUNTIF($A$4:$A$13,">"""),"",

The formula after the comma is of course the long formula we cre
=IF(ROWS($A$4:$A4)>COUNTIF($A$4:$A$13,">"""),"",INDEX(A$4

That ends it!


are some blank cells in between. And we want to use formulas to make it show a list without blanks in between like

s can probably easily do a formula to make a list without the blanks. But array formulas will slow down calculations,
e file. So here’s a method by this forum guru, Marcol, which which does not use arrays.

d is to return rows 4, 5, 6, 8, 10, 11 & 13. These are the non-blank rows.

row number; the ROW formula. So if my formula is:

4, which is “4”. But if you list a range of cells from A4:A13, click inside the formula bar & press F9 to calculate:

bers from Row 4 to Row 13.

ve to make sure these row numbers are shown as “0” instead. To do that, we can do a simple logical test to find

ar & press F9 to calculate, you will see that it creates a list of TRUEs & FALSEs. TRUE means the cell is not a blank, &

TRUE;TRUE;FALSE;TRUE}
ent to the value “1” & FALSE is “0”. So if we were to multiply this logical test with the ROW formula, we would be able

for eg, is not a blank. The logical test will turn “TRUE”, and “TRUE” is equivalent to the value “1”. The ROW of A4 is of
e “1*4”, & returning “4”. This continues until a cell which has blanks (i.e. A7). The logical test turn “FALSE”, hence the
umber is, “0” multiplies by any number will return a “0”.

ROW formula Multiplication


4 4
5 5
6 6
7 0
8 8
9 0
10 10
11 11
12 0
13 13

the multiplication, “0” would be the smallest. 2nd & 3rd smallest numbers are still the other 2 zeroes. So the first
allest row number, and the second value on my list should be the 5th, & so on. To get the number “4”, I can use

st will be incremental by 1 as it goes down (i.e. 4th smallest, 5th smallest, etc). Thus, I can use the ROW formula again
es down (i.e. 4th smallest, 5th smallest, etc). Thus, I can use the ROWS formula to add incremental value of 1

an use the SMALL formula. The array would be our logical test & the ROW number combined together. The “k” would

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

r an array formula. If you press CTRL + SHIFT + ENTER inside the formula bar, “4” should appear. And that’s actually
down & you should see it skip from row 6 to 8 as row 7 is a blank. Row 9 & 12 is also excluded when copied down.

g F9 inside the formula bar to get the results we want. These are array values, mostly to combine with array formulas.
values in the INDEX formula in order not to make this an array formula. The arguments of the INDEX formula go like this:

“column_num” as a number equals or more than 1. This will return us a single value from the “array” chosen. But if
m, it will give us all the values of the “array”. Hope you recall this formula?

he INDEX formula & put a “0” in the “row_num” argument:


4:$A$13),0)

ormula, you don’t have to press CTRL + SHIFT + ENTER anymore:


OW($A$4:$A$13),0),COUNTBLANK($A$4:$A$13)+ROWS($A$4:$A4))
h, but the toughest part is over!

xt in row 4 instead of the just the number 4. Also, the “#NUM!” error should be removed. It will be appearing because in
est, but we only have 10 numbers from 4 to 13. Let’s do the text first. Since we have the row number, all we need is the
w of the array we state. The ones in red are added to our existing formula:
A$4:$A$13<>"")*ROW($A$4:$A$13),0),COUNTBLANK($A$4:$A$13)+ROW(A1)))
ut the 4th row. Copy down & you’ll have them all filled up with text, but the last few with the #NUM! error

nd out how many cells are non-blank. COUNTA comes into mind, but this formula will fail if column A contains
e use this instead:

blank cells. Our 8th value is the one with error, so we can say that if the nth value is greater than the number of
ise, do the formula. To get the nth number, we can use ROW again. So:
A$13,">""")

UE or FALSE. Since ROWS($A$4:$A4) will return “1” & it is greater than 7, it will return FALSE. Our IF statement will put a
ng formula we created, in the FALSE statement. This formula will only return “TRUE” when it is at ROWS($A$4:$A11) where
:$A$13,">"""),"",

urse the long formula we created.


:$A$13,">"""),"",INDEX(A$4:A$13,SMALL(INDEX(($A$4:$A$13<>"")*(ROW($A$4:$A$13)-ROW($A$4)+1),0),COUNTBLANK($A$4:$A$13
n between like

n calculations,

not a blank, &

we would be able

e ROW of A4 is of
ALSE”, hence the
. So the first

OW formula again

er. The “k” would

that’s actually
copied down.

h array formulas.
ormula go like this:

chosen. But if

ppearing because in
r, all we need is the

statement will put a


WS($A$4:$A11) where
1),0),COUNTBLANK($A$4:$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-and-functions/883499-n
horse blue 15
snake red 5
dog green 25
s-and-functions/883499-need-to-calculate-the-average-for-a-column-based-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 there are 4 or less digits: The

ABCDEFGHIJK60120-200 Err:504
ABCD1360 Err:504 =FIND("-",A6&"-")-1
ABCD13160-100 Err:504 For those with existing dashes, the above formul
ABCDEFGH13160 Err:504 it with a dash behind so that there would be no e
ABCDEFGH13060 Err:504 "ABCDEFGHIJK60120-200-"
and in A7:
"ABCD1360-"

=LEFT(A6,FIND("-",A6&"-")-1)
A LEFT formula is then added to obtain all the tex
there are 2 dashes because we added A6&"-", it
text.
"ABCDEFGHIJK60120"
"ABCD1360"

=RIGHT(LEFT(A6,FIND("-",A6&"-")-1)
by stating an array constant of {5,4,3}, you can ac
{"60120","0120","120"}

=--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})
Using LEFT, RIGHT or MID automatically makes it
to numbers. Notice the absence of double quote
{60120,120,120}

=--ISNUMBER(--RIGHT(LEFT(A6,FIND("-",A6&"-")
Using ISNUMBER will determine if those results a
"D1360"
This would be resulting in a FALSE because it's no
{TRUE,TRUE,TRUE}
the double negation then makes it:
{1,1,1}

=MATCH(1,--ISNUMBER(--RIGHT(LEFT(A6,FIND("
The MATCH formula looks for 1 in the array abov
the 1st one is 0 or FALSE.

=INDEX(RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{3,2,
in the array portion of the INDEX formula, somet
{3,2,2} characters instead. So we extract 3 chars
here are 4 or less digits: The last 2 digits before the dash (or end of the string, if no dash)

g dashes, the above formula would return the length before the dash. For those without, the formula combines
so that there would be no error. So it's actually looking a dash for this in A6:

n added to obtain all the text before the dash. FIND would return the position of the 1st dash, so in the case where
cause we added A6&"-", it returns everything before the 1st dash. And for the case of A7, it returns the original

D("-",A6&"-")-1),{5,4,3})
nstant of {5,4,3}, you can actually extract 3 different lengths of 5, 4 & 3 using the RIGHT formula. So the results are:

ND("-",A6&"-")-1),{5,4,3})
MID automatically makes it a text even if you have a cell of pure numbers. Using the double negation converts it back
he absence of double quotes if you press F9 to calculate

T(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3}))
determine if those results are indeed numbers. A6 has no problem, but extracting 5 chars from the right of A7 would be:

ng in a FALSE because it's not a number. For A7, the results would be:

hen makes it:

BER(--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})),0)
ooks for 1 in the array above. Hence it returns 1 for A6 as it finds the 1st instance of 1. for A7, it would return 2, because

A6,FIND("-",A6&"-")-1),{3,2,2}),MATCH(1,--ISNUMBER(--RIGHT(LEFT(A6,FIND("-",A6&"-")-1),{5,4,3})),0))
f the INDEX formula, something similar is used. But this time, instead of extracting {5,4,3} chars, we extract
tead. So we extract 3 chars before the dash if 5 characters before it are all numbers. Otherwise, we the last 2 chars.
<-back
SUMIF using multiple Criteria

Sum up if Column A equals "BOLIVIA" or "BRASIL" or "PERU" Explanation added: Jun 2013
bolivia 10 11
peru 20 =SUMIF($A$5:$A$10,
spore 30 by putting the curly brackets with multiple c
brasil 12 press ENTER with that, it will give you the SU
bolivia 1 to calculate, you will see that 3 individual SU
brasil 3 {11,15,20}

=SUM(SUMIF($A$5:$A$10,{"BOLIVIA","BRA
to add those results, we simply need to plac
on added: Jun 2013

A$5:$A$10,{"BOLIVIA","BRASIL","PERU"},$B$5:$B$10)
the curly brackets with multiple criteria there, you are actually doing multiple SUMIF for the different criteria. If you simply
ER with that, it will give you the SUMIF result of the 1st criteria; Bolivia. If you select that portion of the formula & press F9
e, you will see that 3 individual SUMIF results appear

MIF($A$5:$A$10,{"BOLIVIA","BRASIL","PERU"},$B$5:$B$10))
se results, we simply need to place a SUM In front
nt criteria. If you simply
the formula & press F9
<-back
Lookup Unsorted List & Return Next Highest value

Category Value Result Category Value Result


B 9 100 A 20 200 Category A of Value 20 is between th
A 28 120 B 13 150 Category B of Value 13 is between th
A 25 200
B 3 50 Explanation added: Jun 2013
B 15 150 =$A$5:$A$10=E5
A 18 170 This is the first of our 2 logical tests.
to calculate this portion, you'll get:
{FALSE;TRUE;TRUE;FALSE;FALSE;TRU
Only the 2nd, 3rd & 6th one are Cate

=$B$5:$B$10>=F5
Our next logical test is to check if B5:
{FALSE;TRUE;TRUE;FALSE;FALSE;FALS

=IF($A$5:$A$10=E5,IF(
If we combine both the logical tests
logical tests. So in our case, only the
{FALSE;28;25;FALSE;FALSE;FALSE}
This part is our lookup_array portion

=MIN(IF($A$5:$A$10=E5,IF($B$5:$B
We can then use the same formula &
minimum number. that makes up th
{FALSE;28;25;FALSE;FALSE;FALSE}

=MATCH(MIN(IF($A$5:$A$10=E5,IF(
By using a MATCH formula, we can fi

=INDEX($C$5:$C$10,MATCH(MIN(IF
Combining with INDEX, we are saying
A of Value 20 is between the list of Value 18 & 25. The formula will pick the bigger number between the 2.
B of Value 13 is between the list of Value 9 & 15. The formula will pick the bigger number between the 2.

on added: Jun 2013

first of our 2 logical tests. We need to find out if A5:A10 is equals to the category we want in E5. so if you press F9
e this portion, you'll get:
UE;TRUE;FALSE;FALSE;TRUE}
nd, 3rd & 6th one are Category A

ogical test is to check if B5:B10 is greater or equals to the value in F5. So the results are:
UE;TRUE;FALSE;FALSE;FALSE}

$A$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10))
bine both the logical tests with the IF, it will return the values in B5:B10 only when it meets both the criteria of the
ts. So in our case, only the values in B6 & B7 will show up. The rest will turn FALSE because it fails the logical test/s.
25;FALSE;FALSE;FALSE}
s our lookup_array portion for the MATCH formula.

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

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$10>=F5,$B$5:$B$10)),0)
MATCH formula, we can find the position of 25. since it's the 3rd value, it returns 3.

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$10=E5,IF($B$5:$B$10>=F5,$B$5:$B$10)),0)
g with INDEX, we are saying we want the 3rd value (from the MATCH formula) within C5:C10.
0>=F5,$B$5:$B$10)),0))
<-back
Get Time Diff No Matter Which Cell is bigger

6:00 AM 12:00 PM 6:00:00 Explanation added: Jun 2013


12:00 PM 6:00 AM 18:00:00 =B4-A4
First, you must understand Times are recognised as decimals in Ex
take a later time minus an earlier time, Excel has no problems doin
smaller decimal. But if you copy that down use B5-A5, Excel does
are negative or too large display as ######.". That is because this

The MOD formula works like this; we have a number & a divisor. I
=MOD(13,5)
It returns you the remainder after 13 (number) is divided by 5 (div
=Number - Divisor * INT(Number/Divisor)
so it's:
=13-5*INT(13/5)
INT is taking just the integer of the number we input. 13 divided b

=MOD(B4-A4,1)
If you take a later time minus an earlier time, it will retain the diffe
Using MOD with a positive decimal number will return the same va
=Number - Divisor * INT(Number/Divisor)
=0.25-1*INT(0.25/1)
Rounding 0.25 down to the nearest integer is 0. Hence:
=0.25-1*0

But if you take an earlier time minus a later time, it will be a negati
=-0.25-1*INT(-0.25/1)
This time, rounding down a negative 0.25 is -1. Therefore:
=-0.25-1*-1
that returns a result of 0.75. Convert that to time & that gives us 1
s are recognised as decimals in Excel. 12 pm for eg, is 0.5 if you format the cells as General, because it's half a day. So if you
r time, Excel has no problems doing that. You can try plainly using B4-A4. That is equivalent to a bigger decimal minus a
that down use B5-A5, Excel does not accept that in Time format. It shows a bunch of #s & tells you "Dates and times that
as ######.". That is because this time, you are taking a smaller decimal (6 am) minus a bigger decimal (12 pm).

; we have a number & a divisor. It's much straightforward if they are integers. Say we have this below

er 13 (number) is divided by 5 (divisor). The remaining number that cannot be divided by 5 is 3. It is essentially using:

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

earlier time, it will retain the difference of the positive decimal number. So this is actually 0.5 minus 0.25
mal number will return the same value. You can try calculating by using what I showed earlier:

est integer is 0. Hence:

nus a later time, it will be a negative decimal number. The eg in C5 is doing so by taking 0.25 minus 0.5, returning -0.25

tive 0.25 is -1. Therefore:

nvert that to time & that gives us 18 hours.


it's half a day. So if you
ger decimal minus a
"Dates and times that
mal (12 pm).

essentially using:

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 non-breaking spaces. For e
     a     b           a     b      <-TRIM of no use

To remove it, substitute the non-breaking space with blanks


     a     b           a     b     

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

e. Copy a single character of it & press ESC


<-back
Change single digits to Double

A-10-1 A-10-01 Explanation added: Jun 2013


A-1-1 A-01-01 =COUNTIF(A4,"*-?-*")
A-2-1 A-02-01 We can first find out if the middle portion contains 1 or 2 digits.  Using the ast
is indicating that any unknown single character.  So by using "*-?-*", we are fi
between, followed by another dash, in between any characters (the asterisk).

=SUBSTITUTE(A4,"-",IF(COUNTIF(A4,"*-?-*"),"-0","-"),1)
If there are such instances where the middle portion contains only 1 digit, we
zero in front.  In the scenario where no such instances are found (2 digits in th
instance_num is to say that we only want to substitute the first dash & not to

 =COUNTIF(A4,"*-?")
This is similar to our first one, but concentrating just on the last portion.  It is
that.

=SUBSTITUTE(SUBSTITUTE(A4,"-",IF(COUNTIF(A4,"*-?-*"),"-0","-"),1)
So now, basing on the new substituted text (with 2 digits in between), we aga
we substitute "-" with a "-" when the last portion has 2 digits.  Our instance_n
1st.
ontains 1 or 2 digits.  Using the asterisk is for wildcards; finding any number of characters.  Using a question mark
cter.  So by using "*-?-*", we are finding anything that has a dash, a single character (the question mark) in
ween any characters (the asterisk).

"),"-0","-"),1)
e portion contains only 1 digit, we want to substitute the "-" with "-0".   That makes all single digits contain a
h instances are found (2 digits in the middle), we simply substitute the "-" with a "-" (i.e. no changes).   The
o substitute the first dash & not touch the rest. 

ating just on the last portion.  It is looking for a dash & ending with a single character after any characters before

TIF(A4,"*-?-*"),"-0","-"),1),"-",IF(COUNTIF(A4,"*-?"),"-0","-"),2)
(with 2 digits in between), we again substitute the "-" with a "-0" if the last portion is a single digit.   Similarly,
ortion has 2 digits.  Our instance_num is now 2 because we only want to change the 2nd dash & not touch the
uestion mark

cters before
<-back
Number of a Particular Day Between 2 Dates

Mon Tue Wed Thu Fri Explanation added: Jul 2013


1-Jan-13 27-Jan-13 3 4 4 4 4 http://www.youtube.com/watch?v=

Solution: Barry Houdini


http://www.mrexcel.com/forum/exc
on added: Jul 2013
w.youtube.com/watch?v=p9YOlYL6X7A

Barry Houdini
w.mrexcel.com/forum/excel-questions/542039-what-formula-doing.html
<-back
Number of Workdays (Mon-Sat)

Barry Houdini Excel 2010 Explanation in: http://www.mrexcel.com/forum/excel-questions/54203


1-Jan-13 27-Jan-13 23 #ADDIN? "0000001" - starts from Mon; 0 means to include while 1 is to exclude. In
/excel-questions/542039-what-formula-doing.html
while 1 is to exclude. In this case, only exclude Sun.
<-back
List items that meet criteria (Aggregate)

Dates Name No Action My Method (Array) My Method (Non-Array)


1/1/2013 John 5-Feb-13 Michelle 5-Feb-13 Michelle
2/5/2013 Michelle 1 3-Mar-13 Jack 3-Mar-13 Jack
2/2/2013 Dylan 30-Apr-13 Mike 30-Apr-13 Mike
3/3/2013 Jack 1 30-Apr-13 Doran 30-Apr-13 Doran
4/1/2013 Dave 15-May-13 Anthony 15-May-13 Anthony
4/30/2013 Mike 1
4/30/2013 Doran 1
5/1/2013 Joshua
5/15/2013 Anthony 1
Non-Array) Teethless Mama (Aggregate only in 2010)

5-Feb-13 Michelle

3-Mar-13 Jack

30-Apr-13 Mike
30-Apr-13 Doran

### Anthony
<-back
Convert fractions to decimals

daddylonglegs
15/2 7.5 Excel recognises integer fraction format like 1 1/2 will be 1.5
<-back
Rounddown time to the hour with 4 digits

Mine Teethless mama Explanation added: Jul 2013


12:20 AM 0000 0000
1:50 AM 0100 0100
<-back
Rank Name according to values in descending order

Ep US IL DK Mex Excelisfun
3 5 11 5 9 http://www.youtube.com/watch?v=BzL68bIM7U0&list=PL

IL Mex US DK Ep
h?v=BzL68bIM7U0&list=PLC3D5DEE0852CDB92
<-back
Get Unique List from Multiple Columns

DAVE SUE JOHN MICHAEL


AM PM AM PM AM PM AM PM
MON Support Support Project C Project C Project C Project C Project C Project C
TUES Project A Project A Support Support Project A Project A Support Support
WED Project A Project A Support Support Project A Project A Support Support
THU Project B Project B Project B Project B Support Support Project B Project B
FRI Project B Project B Project B Project B Support Support Project B Project B

Link given by Pete_UK http://www.get-digital-help.com/2009/03/16/unique-values-from-multiple-colum


Project Periods in Schedule
Support
Project C
Project A
Project B
Err:504
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 Haseeb A
T6673758 Doe, Jane USA 9/2/2012 109.31 #VALUE!
ABC Doe, Jane USA 9/4/2012 118.6
T6673758 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
Explanation added: Jul 2013
What the formula does here is create many SUMIFS results that has an incremental row.  So it first
sums up G6 if A6 is "T6673758" & E6 is less than 31 Dec 2012.  Result would be 109.31.  It then increases
by 1 row; sum up G6:G7 if A6:A7 is "T6673758" & E6:E7 is less than 31 Dec 2012.  Result for this
is still 109.31 because row 7 did not meet the criteria. It continues until row 12 & thus gives 7
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 search a value of 600.
When it fails to find an exact match, it will return the last value smaller than 600.  And that would be
590.31.

=OFFSET(G6,,,ROW(G6:G12)-ROW(G6)+1)
This is how to make multiple incremental rows for the different results.  OFFSET will start at G6.
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 then -ROW(G6):
{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)
mental row.  So it first
be 109.31.  It then increases
2012.  Result for this
& thus gives 7

to search a value of 600.


0.  And that would be

ET will start at G6.

n then -ROW(G6):
<-back
Check if Range of Dates fall within another Range of Dates

Start End E.Start E.End


2-Jan-13 3-Jan-13 3 1-Jan-13 31-Jan-13
25-Dec-12 26-Dec-12 0 3-Jan-13 31-Jan-13
1-Feb-13 10-Feb-13 0 29-Dec-12 2-Jan-13
25-Dec-12 28-Dec-12 0
1-Feb-13 5-Feb-13 0
<-back
Get list of 5 highest total cumulative values

id value ID Total by Ron Coderre explained too, by Ron Coderre (with some editing
1 100 4 200 The FREQUENCY function always tacks on an
2 125 #N/A 180 referenced value or that are less than the minimu
3 90 5 150 generate 8 values. Consequently, I needed to exte
4 200 2 125 The FREQUENCY section resolves to this: {1
5 150 6 120 A_Item Freq_Calc
6 120 1 1
3 90 2 1
3 2
4 1
5 1
6 1
3 0 <-dupe, so ignored
blank 0 <-extra value

Basically, that formula works this way INDE

This part calculates the list of totals...Tackin


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

This part returns the nth largest of those tot


LARGE(INDEX(SUMIF($A$5:$A$12,(FREQUE
n Coderre (with some editing to change cell references)
nction always tacks on an additional calculated value for items that are greater than the max
hat are less than the minimum referenced value. So, while FREQUENCY references A5:A11 (7 cells), it will
nsequently, I needed to extend the other references by 1 cell (A5:A12).
ection resolves to this: {1;1;2;1;1;1;0;0}...8 values arranged this way:

-dupe, so ignored
extra value

mula works this way INDEX(A5:A12,MATCH(Largest_Total_Col_A_Item,List_of_Totals_by_Col_A_Item,0))

the list of totals...Tacking on some padding for duplicates "+1/ROW($A$5:$A$12)":


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)

he nth largest of those totals, based on the rank value in Col_D:


MIF($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$12),0),D1)
A$5:$A$12),0),D1)
<-back
VLOOKUP backwards
solution by abousetta
Amount Listed Company Company Amount I’m sure you’ve been told the lookup_value in t
20,000 Yes A B 13000 But what if the Company is on the right side of
13,000 Yes B
18,000 No C The usual workaround is to insert a column bef
other way is to learn the seemingly more comp
CHOOSE. Here’s what you need to input for the
=CHOOSE(index_num, value1, [value2], …)

A simple scenario would be to return A5 or A6.


will pick up A5; because that’s the value1 I inpu
=CHOOSE(1,A5,A6)
And if I were to put in 2 as the index_num, it wi
=CHOOSE(2,A5,A6)

I can also pick up both of the numbers by addin


so let’s add a SUM to it. It will therefore pick up
=SUM(CHOOSE({1,2},A5,A6))

So if we go back to our VLOOKUP case & put in


forcing whatever column that is on the right, to
Pretty brilliant eh? I would still stick to INDEX &
told the lookup_value in the VLOOKUP formula must always be on the left & the data you require on the right.
any is on the right side of Profits?

d is to insert a column before A & copy the Company column over. Then you can do the usual VLOOKUP. The
the seemingly more complex INDEX & MATCH. Here’s a 3rd option by just learning a simple formula called
t you need to input for the formula:
m, value1, [value2], …)

uld be to return A5 or A6. The index_num decides which value would be picked up. So if my index_num is 1, it
se that’s the value1 I input.

n 2 as the index_num, it will pick up A6.

h of the numbers by adding the curly brackets here. But picking up 2 numbers in a cell don’t make sense to Excel,
it. It will therefore pick up A5 AND A6 to sum them up.

ur VLOOKUP case & put in the column for us to look up as value1, and the result column as value2, we are actually
umn that is on the right, to the left.
would still stick to INDEX & MATCH, but I thought this was pretty interesting.
<-back
Inserting Something In The Middle Of Text

Inserting A Semicolon After the comma & 2 letters solution by NBVC


BOSSIER CITY, LAARCADIA, LA BOSSIER CITY, LA;ARCADIA, LA
BOSSIER CITY, LACREW LAKE, LA BOSSIER CITY, LA;CREW LAKE, LA
BOSSIER CITY, LACULLEN, LA BOSSIER CITY, LA;CULLEN, LA
BRANDON, MSJACKSON, MS BRANDON, MS;JACKSON, MS
BRANDON, MSVICKSBURG, MS BRANDON, MS;VICKSBURG, MS
BROOKELAND, TXSHREVEPORT, LA BROOKELAND, TX;SHREVEPORT, LA
BROOKSHIRE, TXFLATONIA, TX BROOKSHIRE, TX;FLATONIA, TX
<-back
Find Position of 1st Upper Case

Solution found by: litrainer


bAc 2

CHAR(65) will return you "A" &


{65;66;67;68;69;70;71;72;73;74;75;76;
and with CHAR(ROW(65:90))
{"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"

the SUBSTITUTE formula will then substitu


SUBSTITUTE(A1,CHAR(ROW(65:90)),0)
so if A1 contains "1bZc", it will return:
{"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1b

note that results appear 26 times, each tim


SUBSTITUTE(A1,CHAR(ROW(INDIRECT("6
this makes every result have a "0" behind
{"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc

so 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;

and the MIN formula will give you the last


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

ormula will then substitute all the upper case letters above if found with a zero. 
HAR(ROW(65:90)),0)
1bZc", it will return:
bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1bZc";"1b

ppear 26 times, each time substituting a single letter. 1st one substituting "A" with "0". it doesnt find any, goes to "B", the
HAR(ROW(INDIRECT("65:90"))),0)&0
esult have a "0" behind:
"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0

t will return:
5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;3}

la will give you the last result. hope that helps


ues from 65 to 90:

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

nd any, goes to "B", then "C", & so on until the last entry. it substitutes "Z" with a "0" & becomes "1b0c". but FIND has a p

1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1bZc0";"1b0c0"}
1b0c". but FIND has a problem, because the rest of the results do not have "0" & will return #VALUE error. so to counter

1bZc0";"1b0c0"}
UE error. so to counter that, the &0 is added.
<-back
Find number & extract the rest from there

abc 1. xyz =FIND({0,1,2,3,4,5,6,7,8,9},A4)


soppppp2c The 10 numbers that exist are 0 to 9. if we were to find 0 to 9 in
{#VALUE!,5,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALU
it tries to find "0", couldn't find it & thus returns VALUE. It then fi

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

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

=MID(A4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A4&"0123456789"))
Once we know the starting position to extract the text, we can us
safe bet would be to put the LEN formula to count the number of
to 9. if we were to find 0 to 9 in A4, it will have a bunch of errors because 1 is the only number that can be found there.
VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!,#VALUE!}
t & thus returns VALUE. It then finds "1" in the 5th position. The rest also couldn’t be found & returned VALUE.

"0123456789")
3456789" to A4, every single number can be found.

A4&"0123456789"))
hind, the original number existing in A4 would in the smallest number found above (the 5th character)

6,7,8,9},A4&"0123456789")),LEN(A4))
tion to extract the text, we can use MID & the number of characters to extract are everything from the number onwards. A
N formula to count the number of characters in A4
<-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. by DonkeyOte
aaa 1a ddd 4d eee
bbb 2b eee 5e zzz
ccc 3c fff 6f ccc 3c
Explanation added: Sep 2013
http://www.excelforum.com/excel-general/699168-nested-vlook-and-match-functions.html
This was the original link shared with me by Pike. DonkeyOte was looking at different sheets to pick up the
values. I made some changes here to refer to different ranges under the same sheet instead.

=VLOOKUP(G6&H6,$A$6:$B$8,2,0)
Since the lookup_value for the VLOOKUP formula can either be in Column G or Column H, we can combine
the 2 cells together. It is just a simple VLOOKUP to search in A6:B8 if "eee" is in A6:A8, and if it is,
return the corresponding row in B6:B8. "eee" does not exist in A6:B8, so it returns an #N/A here.

=VLOOKUP(G6&H6,$D$6:$E$8,2,0)
Another VLOOKUP formula is done, but now to search in D6:E8. "eee" is found this time & would return "5e"
under cell E7.

Instead of using a long IF & ISNA formula, we can use the CHOOSE formula to present the 2 results & LOOKUP
formula to pick the last non-error result. A simple CHOOSE formula works like this:
=CHOOSE(1,E6,E7,E8)
We have 3 values above; E6, E7 & E8. With the index_num as "1", it will return the 1st value; "4d". If you put it as:
=CHOOSE(2,E6,E7,E8)
It will then pick the 2nd value; "5e". But if you put in array constants (the curly brackets) to show values 1 to 3:
=CHOOSE({1,2,3},E6,E7,E8)
This actually shows all 3 values. You can't see it by pressing ENTER because 1 cell can't show the 3 results. Press
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),VLOOKUP(G6&H6,$D$6:$E$8,2,0))
And that is how we are going to store the 2 VLOOKUP formulas. We are also adding a blank here as the 1st value.
This comes in handy when the 2 VLOOKUP formulas cannot find the lookup_value & both returns #N/A. It happens
in cell I7, where "zzz" cannot be found in A6:A8 or D7:D8. These are the following results for I6:I8 respectively:
{"",#N/A,"5e"}
{"",#N/A,#N/A}
{"","3c",#N/A}

=LOOKUP(REPT("Z",255),CHOOSE({1,2,3},"",VLOOKUP(G6&H6,$A$6:$B$8,2,0),VLOOKUP(G6&H6,$D$6:$E$8,2,0))
By using a lookup_value of 255 Zs, it will ensure we are looking for the last possible text that exist. The LOOKUP
formula ignores errors, so from the 3 results above, it will return the last text available (blanks also considered
as text & that's why blank was returned for cell I7 when there are 2 #N/As).
If you put it as:

alues 1 to 3:

esults. Press

the 1st value.


N/A. It happens
espectively:

D$6:$E$8,2,0)))
The LOOKUP
<-back
Variable Cost for Different Qty Range

Qty by AceXL Equivalent to: Link for the explanation of logic shared by: To
2000 200,000 200000 http://mcgimpsey.com/excel/variablerate.htm
3000 400,000 400000
4000 700,000 700000
5000 1,100,000 1100000

1. for the range of 1 - 2000 - cost per unit will be 100


2. for the range of 2001-3000 - cost per unit will be 200
3. for the range of 3001 - 4000 - cost per unit will be 300
4. for the range of 4001 and up - cost per unit will be 400
on of logic shared by: Tony Valko
m/excel/variablerate.html
<-back
No of Days between 2 Dates Within A List of Dates

by Marcol
Total Number of Total Number of
Relevant Year From To Days Out of Date of Exit Date of Entry Days Out of
Country Country
YEAR: ONE 15-Mar-12 14-Mar-13 Err:504 18-Aug-05 8-Sep-05 20
YEAR: TWO 15-Mar-11 14-Mar-12 Err:504 18-Apr-06 18-May-06 29
YEAR: THREE 15-Mar-10 14-Mar-11 Err:504 3-Sep-08 1-Oct-08 27
YEAR: FOUR 15-Mar-09 14-Mar-10 Err:504 12-Aug-09 26-Aug-09 13
YEAR: FIVE 15-Mar-08 14-Mar-09 Err:504 6-Mar-12 25-Mar-12 18
YEAR: SIX 15-Mar-07 14-Mar-08 Err:504 1-Sep-12 11-Sep-12 9
YEAR: SEVEN 15-Mar-06 14-Mar-07 Err:504 1-Sep-09 20-Sep-09 18
<-back
Sorting Numbers/Text Without Blanks

Text & Numbers Source:


Orange 22 http://www.get-digital-help.com/2009...mula-in-excel/
Apple 111
Apple
Mango Grapes
111 Mango
Grapes Orange
22 #VALUE!

Text or Numbers Only


Orange Apple
Apple Grapes
Mango
Mango Orange
Grapes #VALUE!
/2009...mula-in-excel/
<-back
Sum Up Numbers Separated by Dash
Excel 2003 & above Excel 2007 & above Excel 2010
solution by Tony Valko solution by Ghozi Alkatiri solution by XOR LX
22-33-34-35-36 -160 -160 #NAME?
08-28-29-30-35 -130 -130 #NAME?
01-18-23-33-35 -110 -110 #NAME?

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, add 34, & so on. but th
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(A1:C1), it returns all the
{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 are looking at this text be
"-22-33-34-35-36"
and in here, it's saying, from that text above, start from the 1st character (using COLUMN), and 1 character long. but since CO
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 extraction in the next part. it w
{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 character. that will return 3.
the formula, it minus 1 character for the 1st extraction using COLUMN(1:1). so 3-1 is 2. 6 would be deducting 4, because we'r
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). and the number of char
the 4th extraction would again be from text in G6, starting from 4th character (since COLUMN will give 4) & a length of 2 char
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. also, notice that we do
=--(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 are numbers. the 0& is to
explain this

=SUM(IF(MID("-"&G6,COLUMN(1:1),1)="-",--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))
using the logical test we did in the inital stage, we can extract those numbers ONLY IF the single character we extracted are th
Excel 2010
solution by XOR LX
=EVALUATE(SUBSTITUTE('54'!$A5,"-","+"))

nd dash, add 34, & so on. but the first number is missed out because there is no dash in front of 22. hence, the formula

OLUMN(A1:C1), it returns all the column numbers in that range like this:

6, we are looking at this text below:

d 1 character long. but since COLUMN was used, it continues to extract form the 2nd character, 3rd character & so on

extraction in the next part. it will become TRUEs & FALSEs:


E,...............}

t character. that will return 3. if i were to start finding in the 4th character, the next "-" is in character 6. at the end of
ld be deducting 4, because we're doing the when we start finding in the 4th character, COLUMN would become 4. so it's

again). and the number of characters 2 since FIND returns that. that gives us 22 (the 1st number we want to add).
will give 4) & a length of 2 characters again, obtained by FIND. that gives us 33 (the 2nd number we want to add).

hem up. also, notice that we don't want some of those numbers, namely the 2nd, 3rd, 5th, 6th, etc numbers.
eed are numbers. the 0& is to add a 0 in front of those numbers. not sure why is that necessary. maybe Tony can

MN(1:1))-COLUMN(1:1)))))
e character we extracted are the "-".
<-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 CTRL + F3

3. Click on New & put in a name for it. I'm going to name it PicX & in "Refers to", put in the INDEX & MATCH formula

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 in your Quick Access T
Source:
Excel 2010
http://www.youtube.com/watch?v=CEM0pp5SjMU

ress CTRL + F3 Excel 2007


http://www.youtube.com/watch?v=W_GBoDkb2pI
& MATCH formula

that in your Quick Access Toolbar. (the pic in B5 is from Camera Tool)
<-back
Count Number of Times Different Permutation Appears
It will count the number of times the different permutations of C6 appearing in A5:A20 (like 785, 758, 857, 875, 578, 587)

751 solution by Krisztina Szabo (learned from it through bill jelen in the link on the right)
428 785 0
599
803
308
380
510
441
389
785
518
875
587
703
981
930
758, 857, 875, 578, 587)

he link on the right) http://chandoo.org/wp/2013/12/13/what-is-the-coolest-excel-trick-you-have-learned-this-year/


e-learned-this-year/
<-back
Random Entries Without Duplicates
Column E:H will randomly pick up names & they will not appear more than once.

*HC - Helper Columns


2 HC 1 HC 0 HC 0 HC
Alvin 0.937292 1 Alvin Alvin Desmond Benne
Benne 0.271302 4 Elaine Elaine Elaine Desmond
Cathy 0.035136 5 Desmond Desmond Cathy Elaine
Desmond 0.469515 3 Benne Benne Benne Alvin
Elaine 0.9215 2 Cathy Cathy Alvin Cathy

1st solution requires 2 Helper Columns (HC. Column B & C). Column B generates random numbers from 0 to less than 1. It is
number.

2nd solution relies on 1 HC (Column B).

3rd solution is non-reliant on any helper columns (Column B & C).

4th solution is obtained from the link below & slightly amended to my preference
http://www.teachexcel.com/excel-help/excel-how-to.php?i=47847
from 0 to less than 1. It is possible, but unlikely for 2 numbers of the same to turn up. Column C ranks the random

You might also like