How do I populate unique cells from one worksheet to another based on a reference field?

edmund1985

New Member
Joined
Jun 24, 2016
Messages
3
Hi all,

I'm trying to come up with a formula that will populate unique cells in a new worksheet by referencing another worksheet that contains all the data.

So far I've used an INDEX MATCH formula, but that takes across all cells and displays the contents of the desired ones, while producing #N/A for the others.

Example

The data set looks something like this:

Unique IDColour
101White
102White
103Red
104White
105Red
106White

<tbody>
</tbody>

The formula I'm using is below:
=INDEX('Sheet1'!A2,MATCH("White",'Sheet1'!B2,0))

And the result in Sheet 2 looks like this:

Unique ID
101
102
#N/A
104
#N/A
106

<tbody>
</tbody>


I'd like if the '#N/A' cells weren't returned at all, i.e. for it to look like this:

Unique ID
101
102
104
106

<tbody>
</tbody>


Does anyone know if that's possible?? Thanks in advance for any help!!!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
This seems to be a popular question; I see it many times per day :)


Book1
ABCDE
1Unique IDColourUnique IDColour
2101White101White
3102White102
4103Red104
5104White106
6105Red
7106White
Sheet1
Cell Formulas
RangeFormula
D2{=IFERROR(INDEX($A$2:$A$7,SMALL(IF($B$2:$B$7=$E$2,ROW($B$2:$B$7)-ROW($B$1)),ROW()-1)), "")}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Hi WBD,

Thanks for taking a look at it. I tried using your formula but it's producing blank cells unfortunately... I removed the IFERROR function to get a better idea of what's happening and it's giving me #VALUE!

Is there another way of doing it?? Maybe with different formula combinations?

Thanks!
Ed
 
Upvote 0
Well, you'll need to change the cell references etc.

{=IFERROR(INDEX($A$2:$A$7,SMALL(IF($B$2:$B$7=$E$2,ROW($B$2:$B$7)-ROW($B$1)),ROW()-1)), "")}

$A$2:$A$7 : Specifies all the values in the Unique ID column
$B$2:$B$7 : Specifies all the values in the Colour column
$E$2 : Specifies the cell that contains the criteria or you could hard-code this to "White"
$B$1 : Specifies the Colour header cell (i.e. the one that contains "Colour")
ROW()-1 : This is the tricky one. My first value was in D2 so this returns the values 1,2,3,4,5 etc. You might need to change this to return 1 in the first cell you put the formula

WBD
 
Upvote 0
Hi WBD,

I actually got it to work perfectly with the simple example I gave :)

It's given me a few correct results for my actual dataset, although it's missed out certain records sequentially and then at random from various places in the column :(

I should mention that my actual dataset is over 7500 entries long, and the actual unique ID field values are more like:

412361863-1
412568432-1
412568432-2
412357123-1
420535415-1
420957135-1
420957135-2
420957135-3
412693515-1
etc.

<tbody>
</tbody>

Could that be affecting it??
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top