How to create mega formula 2/2

Welcome to the tutorial of creating mega formula. Assuming if you are reading this post you might already have read the first part of it, but if not, have a look here.

In my last post I tried to explain how to create array by using Row() an Indirect() function and then use that array into Mid() function to split up all characters in a string. if you need to do more practice, do it before you read further because now we are going solve the challenge explained in previous post.

Ok back the challenge. this is our image

From the input text we need to extract all numbers sorted ascending. let me show you the formula which will do that.


if you notice, that ROW(INDIRECT(“1:”&LEN(A1))) is repeating five times in the formula and really making it bigger and hard to understand, so let’ do one thing to make it shorter in terms of understanding. lets name this formula something.

row_array = ROW(INDIRECT(“1:”&LEN(A1)))


Alright, so it became shorter but is still hard to understand what it is doing.. let see any explanation of how individual function are working here.

So first of all we need to split up all the characters, so I have used that MID(ROW(INDIRECT(LEN))) technique from previous post. this will split each character and will give an array like {“S”;”1″;”u”;”r”;”2″;”v”;”D”;”4″;”v”;”r”;”5″;”n”;”8″;” “;”s”;”6″;”a”;”9″;”7″;”a”;”0″;”-“;”1″;”-“;”2″;”-“;”3″;”-“;”4″;”-“;”5”}

now each characters are splited but left us with one more challenge, the negative ( -) sign is also coming as a separate element of the array, so it is very difficult to know which value Is negative and which is positive. but I figured out a way.

lets break this formula into two parts first part will return the negative sign if any. Second part will return the values and then we will contact both array element together. First part of the formula is this –


in this formula we are checking if any splited element in array is equal to  “-” sign.  and if it is a negative sign. we need to get the (position – 1;2;3})  of that negative sign, and the above formula will return this array

{“”;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;””;“-“;”-“;”-“;”-“;”- “;””;””;””;””;””}

Now we need second part so that we can concat with this array and this one is actually easy.


we removed all the negative sign from string by using SUBSTITUTE formula and then split the characters. which gave us an array like this.

{“S”;”1″;”u”;”r”;”2″;”v”;”D”;”4″;”v”;”r”;”5″;”n”;”8″;” “;”s”;”6″;”a”;”9″;”7″;”a”;”0″;”1″;”2″;”3″;”4″;”5″}

Now we have both part ready and if we concat them it will look like this.

{“S”;”1″;”u”;”r”;”2″;”v”;”D”;”4″;”v”;”r”;”5″;”n”;”8″;” “;”s”;”6″;”a”;”9″;”7″;”a”;”0″;”-1″;”-2″;”-3″;”-4″;”-5″;#N/A;#N/A;#N/A;#N/A;#N/A}

Now use VALUE Function on this array, this will return error where the element are not number. so it will look like this


Now, use IFERROR on this array to eliminate errors.


will Return


Wow, we got our numbers and now we just need to sort them and as you know we use Small function to sort the numbers, we will use it here. so here is the complete formula you can use to get the output of the challenge.


will Return


Hope you understand what I mean by all this crap, it is really hard to hard explain by writing blog post. but to build you complex formulas you should know what each and individual formula is doing, and how to evaluate functions. you need to know what type of parameters a function will accept and which function can return that type of value.

Alright, see you next time. share your thoughts in comment.

learn all formulas in just INR 500/-

1 reply

Trackbacks & Pingbacks

  1. […] How to create mega formula -2/2 […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *