Combine list data from two worksheets depending on criteria, into a list on a third worksheet

vicomte777

New Member
Joined
Jul 24, 2014
Messages
8
Hi MrExcel experts

there has been many an occasion I have turned to forums such as these for answers, yet have found answers without need of registering. This is the first time I've been unable to work out a solution and thus must plead for your kindness. :confused:

I have three worksheets (excuse the below, I'm making it up off the top of my head for illustration purposes only):

Sheet1
ABCDE
1Title 1
2Category ACategory BCategory CCategory D
31GMCarLike
42FordCarDislike
53BoeingPlaneLike
64SubaruCarDislike
75AirbusPlaneDislike
86DaihatsuCarLike
9

<tbody>
</tbody>


Sheet2
ABCDE
1Title 2
2Category ACategory BCategory CCategory D
37ApplesFruitLike
48WatermelonFruitDislike
59CauliflowerVegetableLike
610CarrotVegetableDislike
7
9

<tbody>
</tbody>

I want to make a list/table on Sheet3 which lists the corresponding Category A number to only those items in the above two worksheets, which are Like'd.

I've attempted nesting Match calls within Index formulas and various vlookup options, however as I'm searching through a column on the right for 'like's and then trying to find their corresponding reference numbers to the left, vlookup doesn't give me much luck.

Notes:
The lists on Sheet1 and Sheet2 are not of uniform length,so was attempting to wrap IFERROR formula around the INDEX(MATCH) combo so that when it finished looking through one worksheet, it would error and go to the Sheet2.
I'm trying to get the subset of column A from both sheets that correspond to values of 'Like' to appear, one after the other.
Once I have these values appearing properly, the Category B and Category C colums can fairly easily be filled through Vlookup formula.

I'm trying to come towards a table which looks like this:

Sheet3
ABCDE
1Title 3
2Category ACategory BCategory C
31GMCar
43BoeingPlane
56DaihatsuCar
67ApplesFruit
79CauliflowerVegetable
8
9

<tbody>
</tbody>

I hope I explained myself well enough...
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Category A seems to consist of a sequence of non-repeating integers. Is this a chance event or really a feature of your data?
 
Upvote 0
Thank you for your response and interest Aladin.

A bit of both.

Each row of data in the actual product has currently got a sequential number next to it, however this is open to being changed by my boss or his boss.

It may be that Sheet1 may find its rows having some unique identifier such as:
A1
A2
A3
A4

and Sheet2

B1
B2
B3
B4

and so on, in which case they won't be sequential and of the integer variety. As these references/unique identifiers are potentially open to change, I didn't want to rely on them in any ROW/S() stuff.

(As an Australian and to a resident of the Netherlands, I also apologize for the unconscious use of airoplanes in my document above. It is very much all over our media, as I'm sure it is for you)
 
Last edited:
Upvote 0
I've got one list adding onto the end of the other, but I need to use Match I guess to make it only list the entries which have corresponding 'Like's within the row. I think my head's gone to wool trying to work this one out so I suspect my ability to code the correct formula to enable it being dragged down may be quite affected.

Code:
=IF(ISERROR(INDEX(Sheet1!$A$3:$A$14, ROWS($A$2:A4))), IF(ISERROR(INDEX(Sheet2!$A$3:$A$12, ROWS($A$2:A4)-ROWS(Sheet1!$A$3:$A$14))), "", INDEX(Sheet2!$A$3:$A$12, ROWS($A$2:A4)-ROWS(Sheet1!$A$3:$A$14))), INDEX(Sheet1!$A$3:$A$14, ROWS($A$3:A5)))
 
Upvote 0
Thank you for your response and interest Aladin.

A bit of both.

Each row of data in the actual product has currently got a sequential number next to it, however this is open to being changed by my boss or his boss.

It may be that Sheet1 may find its rows having some unique identifier such as:
A1
A2
A3
A4

and Sheet2

B1
B2
B3
B4

and so on, in which case they won't be sequential and of the integer variety. As these references/unique identifiers are potentially open to change, I didn't want to rely on them in any ROW/S() stuff.

(As an Australian and to a resident of the Netherlands, I also apologize for the unconscious use of airoplanes in my document above. It is very much all over our media, as I'm sure it is for you)

Ok, they do not form necessarily a sequence, but they are non-repeating, I presume.

Sheet1, A1:D8, and Sheet2, A1:D6, house the relevant data. The headers are in row 2 on each sheet.

The processing occurs in Sheet3, A:C...

5
Title 3
Category A
Category B
Category C
1
GM
Car
3
Boeing
Plane
6
Daihatsu
Car
7
Apples
Fruit
9
Cauliflower
Vegetable

<TBODY>
</TBODY>

Function ArrayUnion(ParamArray Arg() As Variant) As Variant
' Code: Juan Pablo González
' Spec: Aladin Akyurek
' May 4, 2003
' Ref: TinyURL.com - shorten that long URL into a tiny URL
Dim TempUnion() As Variant
Dim i As Long, Itm As Variant, Ctr As Long
For i = LBound(Arg) To UBound(Arg)
Arg(i) = Arg(i)
If IsArray(Arg(i)) Then
For Each Itm In Arg(i)
Ctr = Ctr + 1
ReDim Preserve TempUnion(1 To Ctr) As Variant
TempUnion(Ctr) = Itm
Next Itm
Else
Ctr = Ctr + 1
ReDim Preserve TempUnion(1 To Ctr) As Variant
TempUnion(Ctr) = Arg(i)
End If
Next i
ArrayUnion = TempUnion
End Function


Define the following names using Formulas | Name Manager...

CatA as referring to:
Rich (BB code):
=arrayunion(Sheet1!$A$3:$A$8,Sheet2!$A$3:$A$6)

CatD as referring to:
Rich (BB code):
Rich (BB code):
=arrayunion(Sheet1!$D$3:$D$8,Sheet2!$D$3:$D$6)


and Ivec as referring to:
Rich (BB code):
=ROW(INDIRECT("1:"&COLUMNS(CatA)))

A1, control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(CatA<>"",IF(CatD="Like",
  MATCH("~"&CatA,CatA&"",0))),Ivec),1))

A3, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IF(ROWS($A$3:A3)<=$A$1,
  INDEX(CatA,SMALL(IF(FREQUENCY(IF(CatA<>"",IF(CatD="Like",
  MATCH("~"&CatA,CatA&"",0))),Ivec),Ivec),ROWS($A$3:A3))),"")

B3, just enter and copy down:
Rich (BB code):
=IF($A3="","",LOOKUP(REPT("z",255),CHOOSE({1,2},
  VLOOKUP($A3,Sheet1!$A$3:$B$8,2,0),
  VLOOKUP($A3,Sheet2!$A$2:$B$6,2,0))))

C3, just enter and copy down:
Rich (BB code):
=IF($A3="","",LOOKUP(REPT("z",255),CHOOSE({1,2},
  VLOOKUP($A3,Sheet1!$A$3:$C$8,3,0),
  VLOOKUP($A3,Sheet2!$A$2:$C$6,3,0))))

See the workbook that implements the foregoing...
https://dl.dropboxusercontent.com/u/65698317/vicomte777 conditional sublist.xlsm
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,782
Members
449,259
Latest member
rehanahmadawan

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