Hi,
I have a problem and was hoping you could help me with it. I have two columns, I want to keep column 1 static and find any values in Column 2 and place them in the same order as found in Column 1. I am attaching a spreadsheet to help explain my question. Column A and B are the two columns and Column D is the desired answer.
Thanks
Nimesh
You have values in column-B that do not appear in column-A so you cannot, as I see it, get the results you show in column-D.
Try this formula in cell E2 and copied down.
=INDEX($B$2:B6,MATCH(A2,$B$2:B6,0))
That works partially, it shows the values from Column A in the right place but shows #N/A when it does not find values from A in B. hope I am making sense.
Thanks for the reply
Exactly the point I made in previous post - column-B contains values not found in column-AThat works partially, it shows the values from Column A in the right place but shows #N/A when it does not find values from A in B.
If you want to show a blank instead of the #N/A error, use this formula.
=IF(ISNA(INDEX($B$2:B6,MATCH(A2,$B$2:B6,0))),"",INDEX($B$2:B6,MATCH(A2,$B$2:B6,0)))
I am not sure if this can be done, but is it possible to put the values from Column B which were not found in column A in the blank cells ?
Thanks,
Nimesh
Palmetto is correctm, just replace "" for your needed column data
reeditred from Palmettos code
=IF(ISNA(INDEX($B$2:B6,MATCH(A2,$B$2:B6,0))),B2,INDEX($B$2:B6,MATCH(A2,$B$2:B6,0)))
Vora
If as implied OP is using XL2007 you might want to opt for the IFERROR function over the double evaluation
Another alternative might be to use REPT ?
=REPT($A2,ISNUMBER(MATCH($A2,$B$2:$B$6,0))
Last edited by DonkeyOte; 09-12-2009 at 04:57 AM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Hi Nimesh,
It is impossible to do it with formulae (or may be extremely difficult).
However, it can be very easily done with the help of a simple macro. I have written one. The logic is to add all the values of Column B not found in Column A into an array and then use the array values to fill the blank rows in the resulting column. The result column in my code is E. The code used is:
However, I am attaching the Excel file for your reference. Be sure to Enable Macros when you open the file & click on 'Run Macro'.Code:Dim i As Long, j As Long Dim flag As Boolean Dim notfound As New Collection For i = 2 To Sheets(1).Range("B" & Rows.Count).End(xlUp).Row flag = False For j = 2 To Sheets(1).Range("A" & Rows.Count).End(xlUp).Row If Sheets(1).Cells(i, 2).Value = Sheets(1).Cells(j, 1).Value Then flag = True Exit For End If Next If flag = True Then Sheets(1).Cells(j, 5).Value = Sheets(1).Cells(i, 2).Value Else notfound.Add (Sheets(1).Cells(i, 2).Value) End If Next j = 1 For i = 2 To Sheets(1).Range("B" & Rows.Count).End(xlUp).Row If Sheets(1).Cells(i, 5).Value = "" Then Sheets(1).Cells(i, 5).Value = notfound.Item(j) j = j + 1 End If Next
--Karan--
Originally Posted by nimesh
Not so sure about that, this variant might work though it is designed to only list missing items once - ie if F appears twice it will only list F once in the blanksOriginally Posted by karan
Again this utilises IFERROR approach.Code:D2: =IFERROR(REPT($A2,MIN(1,MATCH($A2,$B$2:$B$6,0))),INDEX($B$2:$B$6,MATCH(1,INDEX(ISNA(MATCH($B$2:$B$6,$A$2:$A$6,0))*ISNA(MATCH($B$2:$B$6,$D$1:$D1,0)),0),0))) copied down
(also assumes D1 is blank or does not contain a value that can otherwise be located in B2:B6)
Last edited by DonkeyOte; 09-12-2009 at 05:06 AM. Reason: added note re: D1 content
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks