Hi ,
I will try to explain , but the explanation will span several posts , since there are many elements to the formula.
First , let us consider the named range rng. The formula for this is :
=TRIM(MID(SUBSTITUTE(LOOKUP("zzz",Hoja1!$A$1:$A2)," ",REPT(" ",99)),1+99*(ROW(Hoja1!$1:$20)-1),99))
There are 4 components of this formula , using the functions TRIM , MID , SUBSTITUTE and LOOKUP. The REPT and the ROW functions are a part of the SUBSTITUTE and MID functions respectively.
We can straightaway eliminate the TRIM function because it is the simplest of them all ; it is removing the unwanted spaces which were introduced by the REPT function.
Since the MID and SUBSTITUTE functions are working in tandem , we will consider them later , after we have seen how the LOOKUP function works.
To understand how the LOOKUP function works , do the following :
In a blank worksheet , enter the values 1 , 4 , 7 and 10 in cells A1 , A6 , A11 and A16 respectively i.e. cell A1 has 1 in it , cell A6 has 4 in it , A11 has 7 in it and A16 has 10 in it.
Now , in cell C1 enter the formula :
=LOOKUP(99,A$1:A1)
and drag it down till cell C20.
You will see that the cells between C1 and C20 have been filled with data ; there are no blank cells unlike in column A. The cells between C1 and C5 are filled with the data in A1 , the cells between C6 and C10 are filled with the data in A6 ,and so on.
Two points must be noted in this formula :
1. The 99 in the LOOKUP function is because the data is numeric. This will not work if the data is alphabetic or alphanumeric.
2. Even if the data is numeric , the 99 works in this case because it is bigger than the biggest data value ; for this reason , you might sometimes see the same formula using a value such as 9.9999E+307 , which is the biggest number possible to be entered in a cell in Excel. Obviously , using such numbers is not necessary ; all that is required is that the number used be bigger than any number within the data range.
To further understand this formula , change the data in A1 from 1 to a ; change the data in A11 from 7 to b.
The results of the formula are now an error value in the cells C1 to C5 , and the value 7 in the cells C11 through C20.
The reason for the error value is that the LOOKUP function is no longer able to recognize the numeric value of the data in A1 , the value in C1 is an error value , and the remaining cells from C2 to C5 are also filled with the same error value.
The reason for the cells C11 through C20 to have 7 in them despite the intervening character b in cell A16 is because the LOOKUP function is looking for a numeric value (since the first parameter , 99 , is a number) , and ignores the alphabetic character b.
Any doubts ?
Narayan