Need an INDEX function to create a horizontal array fron a two dimensional pivot table for merging data into forms

avoiss

New Member
Joined
Jul 31, 2013
Messages
7
Hi - i am using a 6k record flat file with submissions records that I have turned into a pivot table for a two dimensional array, but need to get the associated content for each submission using index and match from the submission ID - in some cases there are 1000 associated records per submission ID. I need to add the associated content into columns so I can then extract all the data into merge forms.

This is two days and counting and I am not getting anywhere. At this point I can at least get data, but it is exactly the same across the rows. I have created a small subset of data for testing and here is where I have ended up with the formula.

=INDEX(testtable[RPN],MATCH($F4,testtable[SubmissionID]))

1 2 3
SubmissionID Name RPN
123 SubOne 11111 SubmissionID Name Count of RPN RPN1 RPN2 RPN3 RPN4 RPN5 RPN6 RPN7
123 SubOne 22222 123 SubOne 7 77777 77777 77777 77777 77777 77777 77777
123 SubOne 33333 555 SubTwo 5 133332 133332 133332 133332 133332 133332 133332
123 SubOne 44444 998 SubThree 3 166665 166665 166665 166665 166665 166665 166665
123 SubOne 55555
123 SubOne 66666
123 SubOne 77777
555 SubTwo 88888
555 SubTwo 99999
555 SubTwo 111110
555 SubTwo 122221
555 SubTwo 133332
998 SubThree 144443
998 SubThree 155554
998 SubThree 166665
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi avoiss,

Are the actual RPN values numeric as they are in your example? If so, you could get your desired result with a PivotTable.
 
Upvote 0
Hi - the original table is a 6k flat file for a submission ID for each one-to-many RPN. I created a Pivot table to do that association, but I need to get the RPNs now into one horizontal line with its associated submission file under headings RPN1, RPN2, RPN3, RPN4 .... RPN 350. Can I upload my test file for you to review somewhere?
 
Upvote 0
I think I understand the layout of your source data and what you are wanting to do. I asked whether the actual RPN values are numeric as they are in your example because if they are you report horizontally in datafields of a Pivot. If the actual RPNs are a mix of letters and numbers, then a PivotTable isn't feasible.
 
Upvote 0
Sorry - I get it - The RPNs are alphanumeric, quite lengthy, and in some cases contain hyphens.
 
Upvote 0
Would a VBA macro solution work for you? This can be done with formulas, but for me it's easier to do with VBA.
 
Upvote 0
Hi - my preference would be a formula so we don't have to switch to XLM - but certainly not required - I will be just so happy to have a solution..... :)
 
Upvote 0
Here's a formula-based solution. Assuming that you have a source data table named "testtable" beginning at Cell A1...


Excel 2013
ABC
1SubmissionIDNameRPN
2123Sub One11111
3123Sub One22222
4123Sub One33333
5123Sub One44444
6123Sub One55555
7123Sub One66666
8123Sub One77777
9555Sub Two88888
10555Sub Two99999
11555Sub Two111110
12555Sub Two122221
13555Sub Two133332
14998Sub Three144443
15998Sub Three155554
16998Sub Three166665
Sheet1


Enter these formulas then copy down and across....


Excel 2013
EFGHIJKLMNO
1SubmissionIDNameCount of RPNRPN1RPN2RPN3RPN4RPN5RPN6RPN7RPN8
2123Sub One711111222223333344444555556666677777
3555Sub Two58888899999111110122221133332
4998Sub Three3144443155554166665
Sheet1
Cell Formulas
RangeFormula
F2=IF(LEN($E2),VLOOKUP($E2,testtable[[SubmissionID]:[Name]],2,0),"")
G2=IF(LEN($E2),COUNTIF(testtable[SubmissionID],$E2),"")
E2{=IFERROR(INDEX(testtable[SubmissionID], SMALL(IF(FREQUENCY(IF(testtable[SubmissionID]<>"", MATCH(testtable[SubmissionID],testtable[SubmissionID],0)), ROW(testtable[SubmissionID])-ROW($A$2)+1), ROW(testtable[SubmissionID])-ROW($A$2)+1),ROWS(E$2:E2))),"")}
H2{=IF(AND(LEN($E2),COLUMNS($H2:H2)<=$G2),INDEX(testtable[RPN],SMALL(IF($E2=testtable[SubmissionID], ROW(testtable[RPN])-ROW(C$2)+1),COLUMNS($H2:H2))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi Jerry - I don't know how to thank you! This is a very elegant solution!!! I cannot thank you enough!!!!

I know you are incredibly busy - so if and when you can spare a moment - can you help me understand the H2 CSE formula you have brilliantly developed above? - I have the C+S+E Mastering Excel Array Formulas book - is there a reference in the book you can point me to and I can review?
 
Upvote 0
I don't have the CSE Mastering Excel Array Formulas book. However, based on a workbook of examples from the book I found online, I think the formulas using SMALL() in Chapter 19 are similar. The primary differences are the book's example matches 2 criteria instead of 1, and the unique matches were listed vertically instead of horizontally.

If you have any questions about how the formula I showed in H2 works, I'd be glad to try to explain it.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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