Have an issue- can this be solved with a formula or does it need coding?

dframe44

New Member
Joined
Jun 11, 2015
Messages
3
Heres my problem-
I have a sheet1 with 'parent ID's' in Column A and 'Asset IDs' in Column B, and a sheet2 with 'child IDs' In column A and 'Parent IDs' in column B.
I need to populate a new worksheet with 3 columns- one with the Child IDs, one with the matching parent ID's, and one with the matching Product ID's.
I thought an Index-Match would solve this, but the main issue is that there are multiple 'Assets' per 'Parent', and I need index-match to create multiple child entries. For example,

Worksheet 1

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>
Parent IDAsset ID
123xyz
123abc
123def
123ghi
456jkl
456mno
456pqr

<tbody>
</tbody>

Worksheet 2

Child IDParent ID
789123
111123
222456

<tbody>
</tbody>


I would need worksheet 3 to look like this
Child IDParent IDAsset ID
222456jkl
222456mno
222456pqr
111123xyz
111123abc
111123def
111123ghi
789123xyz
789123abc
789123def
789123ghi

<tbody>
</tbody>

Does anyone have a macro or a formula suggestion for me to use? I've been struggling trying to get INDEX-MATCH to work all day, and am out of ideas. Help would be greatly appreciated!
-David
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I may be missing something, but it looks like you could copy sheet1 to a new sheet in column B and then use index-match in column a.
 
Upvote 0
Sheet 3 would be what I would be creating- if I copied sheet 1 into a new worksheet it would only give me 7 rows to index against, and the end product (sheet 3) would need 11 rows.
Just to note, i created sheet 3 manually here based off the information in sheet 1 and sheet 2; in practice, sheet 1 and sheet 2 would have thousands of rows
 
Upvote 0
Yup, missed it. I would start by formatting the two lists as tables, I named them Table_Child and Table_Assets.
Add a column to the Table_Child called Asset Count, formula =COUNTIF(Table_Assets[Parent ID],[@[Parent ID]])
Add another column to the table, Cum Assets, formula =SUM(OFFSET(Table_Child[[#Headers],[Asset Count]],1,0,ROW([@[Asset Count]])-1))
On the new sheet in:
A2 =INDEX(Table_Child[Child ID],IFERROR(MATCH(ROW()-ROW($A$2),Table_Child[Cum Assets],1)+1,1))
B2 =INDEX(Table_Child[Parent ID],MATCH(A2,Table_Child[Child ID],0))
C2 = OFFSET(Table_Assets[[#Headers],[Parent ID]],MATCH(B2,Table_Assets[Parent ID],0)+COUNTIFS($A$2:$A2,A2,$B$2:B2,B2)-1,1)
Copy down until you get errors.
 
Upvote 0
C Moore,

Thats impressive. A colleague & I came to the conclusion that using SQL was more suited to this task; it was a hammer, while Excel was a rock.
Still, I'm going to try to recreate the formula you just gave me when I have some free time.
Thank you so much for your time! It is most appreciated!

-Dave
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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