F occur once or more in a given row?
Aladin
=================
Aladin
"F" occurs normally once and I will manually deal with other instances.
Have looked at INDEX(MATCH) and the problem, again is that MATCH will not return the correct column number if the exact text is not used as the first arguement.
Thanks for looking into this!
Mike
> "F" occurs normally once and I will manually deal with other instances.
Mike --
I'll assume the following sample which is in A1:C4.
{35489,35490,35491; "C","F","X";"C","LOF","Y";"C","Y","OLF"}
Big numbers are serialized dates, so don't worry about them.
In E2 enter: =IF(SUMPRODUCT((ISNUMBER( SEARCH("F",A2:C2))+0))=1, INDEX($A$1:$C$1, SUMPRODUCT((ISNUMBER( SEARCH("F",A2:C2)))*(COLUMN(A1:C1)))),"?")
Copy down this as far as needed.
This formula will return a question mark if either N("F")=0 or N("F") > 1.
Aladin
==================
Aladin
I'm very impressed!
Perhaps in another year, I would have considered using SUMPRODUCT(ISNUMBER(SEARCH(INDEX))) combination...Wow!
You definately are an Excel expert.
Much appreciated and if you are ever in Dublin I'll buy you a few Extra Cold Guinness, or whatever your preference.
Thanks again!
Mike
Aladin
I'm experiencing a side-effect that you may be able to answer.
If I put the formula to the left of the data the results are offset (to the right of the lookup data) by the number of columns to the left the formula is in.
Using Office 2000 SP2
Mike I'm very impressed!
> If I put the formula to the left of the data the results are offset (to the right of the lookup data) by the number of columns to the left the formula is in.
Mike --
If you inserted a new column A, then you need to adjust the range for INDEX. If unsure, post the formula from its new location.
Aladin
Aladin
I understand that the INDEX would change if a column was inserted.
The side-effects happen despite naming the correct index range.
Something about the formula that doesn't like columns to the left of the defined index.
Mike
Mike
I can't reproduce the phenomenon. Please either post the formula or send me your workbook.
Aladin
The Problem Reviewed:
A B C E
01-Jan-01 02-Jan-01 03-Jan-01 RETURN VALUES
C O LF 03-Jan-01
COLF (blank) (blank) 01-Jan-01
CO LF (blank) 02-Jan-01
I want to search for all occurences, by row, of the letter "F" (representing [finished]) and populate the return values column (E) with the appropriate date that all "F"'s were detected.
The solution, provided by Aladin (thank-you!), does not include any of the Excel Lookup functions! Amazing as this seems, it's true that the lookup functions fail miserably when trying to do this type of thing.
I'm sure a macro could be developed quickly in VB, but I've not tried that approach as I wanted to use the built-in functions if possible.
The solution requires the use of 4 functions:
SUMPRODUCT
ISNUMBER
SEARCH
INDEX
(NOTE: I'm using Office 2K SP2. I've not tested this on earlier versions or XP, so your results may vary.)
The key to this solution working is identifying the correct INDEX range. This point cannot be more adequately stressed. More on this later.
Create a table with all data in colums A-C (as above)
Format row 1 as dates (dd-mmm-yyyy or preference)
Using the following formula in cell E2:
=IF(SUMPRODUCT((ISNUMBER( SEARCH("F",A2:C2))+0))=1, INDEX($A$1:$C$1, SUMPRODUCT((ISNUMBER( SEARCH("F",A2:C2)))*(COLUMN(A1:C1)))),"?")
Copy down to row E4 and the solution is there!
Excellent formula and kudos to Aladin.
In the case where the data is populated in columns other than A-C is where you need to pay particular attention to the INDEX range.
For example, in the table that you created insert a column in A (source data now moves to B-D), what happens to your results? What would you think you need to change in the formula so that your results were the same? It may be very obvious that the INDEX range needs to be changed, but what would you change it to?
It isn't obvious and I'm am emphasising this for a reason.
The SUMPRODUCT part delivers a column number: if our value is "F" in column C for example, we get 3, which is precisely the column number of "F". INDEX must get the 3rd value from the range A2:D2(thus not from the range B2:D2 which seems natural).
Therefore the formula should be changed to:
=IF(SUMPRODUCT((ISNUMBER( SEARCH("F",B2:D2))+0))=1, INDEX($A$1:$D$1, SUMPRODUCT((ISNUMBER( SEARCH("F",A2:C2)))*(COLUMN(A1:C1)))),"?")
Aladin offers yet another solution that is less troublesome:
=IF(SUMPRODUCT((ISNUMBER( SEARCH("F",B2:D2))+0))=1, INDIRECT(ADDRESS(ROW($2:$2), SUMPRODUCT((ISNUMBER( SEARCH("F",B2:D2)))*(COLUMN(B2:D2))))),"?")
Hope this helps you as much as it helped me!
Thanks again Aladin!
Mike