Excel Tricks Learned
Excel Tricks Learned
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".
="#"&"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.
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".
return #N/A.
<-back
Formula to Count like being Autofiltered Solution by JosephP
Selection Database
Interest Count
Sports 5 ✘ 1
Music 2 ✘ 1
Movies 3 ✘ 1
Explanation for F3
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.
$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
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}
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),
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
(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
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,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}
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
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"}
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
ank cell, excel returns a 0. you can try highlighting this in the
0.25;0;0.166666666666667;0.166666666666667;0.5;0.25;0.5;0.
red.
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.
=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
=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
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
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])
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,
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:
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
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
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
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])
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,
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.
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}
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))
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
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
=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.
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 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.
=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
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
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
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
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,
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
=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
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)
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:
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
Hence, the smallest number for "abc" is actually the 4th largest number in my
)*B4:B13,0)
=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
=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:
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
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}
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$
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
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
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.
4, which is “4”. But if you list a range of cells from A4:A13, click inside the formula bar & press F9 to calculate:
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”.
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?
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,">"""),"",
n calculations,
we would be able
e ROW of A4 is of
ALSE”, hence the
. So the first
OW formula again
that’s actually
copied down.
h array formulas.
ormula go like this:
chosen. But if
ppearing because in
r, all we need is the
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:
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
=$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.
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
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:
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:
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
essentially using:
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
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:
=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
Barry Houdini
w.mrexcel.com/forum/excel-questions/542039-what-formula-doing.html
<-back
Number of Workdays (Mon-Sat)
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
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
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
n then -ROW(G6):
<-back
Check if Range of Dates fall within another Range of Dates
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
-dupe, so ignored
extra value
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.
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
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}
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
=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
=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
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
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
=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:
d 1 character long. but since COLUMN was used, it continues to extract form the 2nd character, 3rd character & so on
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
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)
1st solution requires 2 Helper Columns (HC. Column B & C). Column B generates random numbers from 0 to less than 1. It is
number.
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