match index formula to pickup a certain condition

allandiep

New Member
Joined
Aug 18, 2012
Messages
4
Hi guys,

I've tried fixing this problem by myself and have now given up.

Formula I am querying about is: =INDEX(INVOICE!1:1048576,MATCH(A1,INVOICE!A:A,0)+1,2)&""

On my main sheet, A1 is where I type the invoice number. My second sheet where I enter all the information is called INVOICE! and within A:A I enter all the invoices and B:B all the stationary description corresponding to the invoice. e.g. invoice 1 = pen, invoice 2 = pencil, invoice 2 = scissor, invoice 3 = pen. In this example, there will be 4 rows

On my main sheet, I have the above formula, and it returns the description by matching what invoice number I enter into A1. The first line will return the same row as the invoice number, the second line when moving the formula down will return the row below (adding +1 to formula per above) the column matching the number, the third will show 2 rows below (by adding +2), and so on.

My problem is, when I type in invoice number 1 on the main sheet, it will pick up the items on my invoice sheet i.e. invoice 1 = pen, pencil, scissor, pen. I only want invoice 1 to show invoice 1 stuff, not the other invoices. In addition, when I type invoice 2, it will pick up pencil, scissor, pen. However, I only want invoice 2 to show pencil and scissor.


My index / match formula needs an IF condition to select which data to extract, I don't know which one. Or, it needs another column to make the invoice number within the invoice sheet unique.


Please help.
 
Hi guys,

I've tried fixing this problem by myself and have now given up.

Formula I am querying about is: =INDEX(INVOICE!1:1048576,MATCH(A1,INVOICE!A:A,0)+1,2)&""

On my main sheet, A1 is where I type the invoice number. My second sheet where I enter all the information is called INVOICE! and within A:A I enter all the invoices and B:B all the stationary description corresponding to the invoice. e.g. invoice 1 = pen, invoice 2 = pencil, invoice 2 = scissor, invoice 3 = pen. In this example, there will be 4 rows

On my main sheet, I have the above formula, and it returns the description by matching what invoice number I enter into A1. The first line will return the same row as the invoice number, the second line when moving the formula down will return the row below (adding +1 to formula per above) the column matching the number, the third will show 2 rows below (by adding +2), and so on.

My problem is, when I type in invoice number 1 on the main sheet, it will pick up the items on my invoice sheet i.e. invoice 1 = pen, pencil, scissor, pen. I only want invoice 1 to show invoice 1 stuff, not the other invoices. In addition, when I type invoice 2, it will pick up pencil, scissor, pen. However, I only want invoice 2 to show pencil and scissor.


My index / match formula needs an IF condition to select which data to extract, I don't know which one. Or, it needs another column to make the invoice number within the invoice sheet unique.


Please help.

Could you post your data with desired result?
You can download and install two of the following programs:

HTLMaker

or
Excel Jeanie


or when using Internet Explorer just put borders around your data in Excel and copy those cells into your post
 
Upvote 0
Let me try if this works.

First time using excel jeanie.

Sheet 1 is as follows:

Excel Workbook
A
11
2scissor
3pen
4pencil
Sheet1


Sheet 2 is as follows where I enter all my data:

Excel Workbook
AB
1INVOICEDESCRIPTION
21scissor
32pen
42scissor
53pencil
INVOICE


Formula I am looking for is very similar to this one, however this one returns columns, I need rows:

Excel Workbook
ABCD
1NameCountTracking Num List
2a1456 
3b2487454
4c1456 
Sheet1
 
Upvote 0
Hi guys,

I've rearranged / simplified my question. Per below, when I enter in "a" in cell A2, cells b4:b6 containing the formula should return 100, blank, and blank as there is only 1 count of "a" in sheet 2 containing the data.

However, when I enter in "b" in cell A2, I want cells b4:b6 to return 200,300, and blank respectively, as per sheet 2 containing the data.

I am at a lost and can't seen to figure this out. Please help.

Sheet 1 (extraction sheet)

Excel Workbook
AB
1NameCount
2b2
3
4200
5?
6?
Sheet1



Sheet 2 (data / source sheet)

Excel Workbook
AB
1NameTracking
2a100
3b200
4b300
5c400
Sheet2
 
Upvote 0
Excel 2010
AB

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FFFFFF"]Name[/TD]
[TD="bgcolor: #FFFFFF"]Count[/TD]

[TD="align: center"]2[/TD]
[TD="bgcolor: #FFFFFF"]a[/TD]
[TD="bgcolor: #FFFFFF, align: right"]100[/TD]

[TD="align: center"]3[/TD]
[TD="bgcolor: #FFFFFF"]b[/TD]
[TD="bgcolor: #FFFFFF, align: right"]200[/TD]

[TD="align: center"]4[/TD]
[TD="bgcolor: #FFFFFF"]b[/TD]
[TD="bgcolor: #FFFFFF, align: right"]300[/TD]

[TD="align: center"]5[/TD]
[TD="bgcolor: #FFFFFF"]c[/TD]
[TD="bgcolor: #FFFFFF, align: right"]400[/TD]

[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet2


Excel 2010
ABC
Name Count
Excel 07/10

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: center"]b[/TD]
[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: center"]200[/TD]
[TD="align: center"]200[/TD]

[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: center"]300[/TD]
[TD="align: center"]300[/TD]

[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]=COUNTIF(Sheet2!$A$2:$A$14,A2)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]B3[/TH]
[TD="align: left"]{=IF(ROWS($A$2:$A2)<=$B$2,INDEX(Sheet2!$B$2:$B$200,SMALL(IF(Sheet2!A$2:A$200=$A$2,ROW($A$2:$A$200)-ROW($A$2)+1),ROWS($A$2:A2))),"")}[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]C3[/TH]
[TD="align: left"]{=IFERROR(INDEX(Sheet2!$B$2:$B$200,SMALL(IF(Sheet2!A$2:A$200=$A$2,ROW($A$2:$A$200)-ROW($A$2)+1),ROWS($A$2:A2))),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi guys,

I've rearranged / simplified my question. Per below, when I enter in "a" in cell A2, cells b4:b6 containing the formula should return 100, blank, and blank as there is only 1 count of "a" in sheet 2 containing the data.

However, when I enter in "b" in cell A2, I want cells b4:b6 to return 200,300, and blank respectively, as per sheet 2 containing the data.

I am at a lost and can't seen to figure this out. Please help.

Sheet 1 (extraction sheet)

Sheet1

AB
NameCount
b
?
?

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 64px;"><col style="width: 64px;"></colgroup><tbody>
[TD="bgcolor: #CACACA, align: center"]1[/TD]

[TD="bgcolor: #CACACA, align: center"]2[/TD]

[TD="align: right"]2[/TD]

[TD="bgcolor: #CACACA, align: center"]3[/TD]

[TD="bgcolor: #CACACA, align: center"]4[/TD]
[TD="align: right"]200[/TD]

[TD="bgcolor: #CACACA, align: center"]5[/TD]

[TD="bgcolor: #CACACA, align: center"]6[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
B2=SUMPRODUCT((Sheet2!$A$2:$A$5=$A2)+0)
A4{=IF(N($B2),IF(COLUMNS($A4:A4)<=$B2,INDEX(Sheet2!$B$2:$B$5,SMALL(IF(Sheet2!$A$2:$A$5=$A2,ROW(Sheet2!$A$2:$A$5)-ROW(Sheet2!$A$2)+1),COLUMNS($A4:A4))),""))}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


Sheet 2 (data / source sheet)

Sheet2

AB
Name Tracking
a
b
b
c

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 64px;"><col style="width: 64px;"></colgroup><tbody>
[TD="bgcolor: #CACACA, align: center"]1[/TD]

[TD="bgcolor: #CACACA, align: center"]2[/TD]

[TD="align: right"]100[/TD]

[TD="bgcolor: #CACACA, align: center"]3[/TD]

[TD="align: right"]200[/TD]

[TD="bgcolor: #CACACA, align: center"]4[/TD]

[TD="align: right"]300[/TD]

[TD="bgcolor: #CACACA, align: center"]5[/TD]

[TD="align: right"]400[/TD]

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Looks like you nbewed to replace COLUMNS with ROWS in that CSE-formula.
 
Upvote 0
Hi guys,

I've rearranged / simplified my question. Per below, when I enter in "a" in cell A2, cells b4:b6 containing the formula should return 100, blank, and blank as there is only 1 count of "a" in sheet 2 containing the data.

However, when I enter in "b" in cell A2, I want cells b4:b6 to return 200,300, and blank respectively, as per sheet 2 containing the data.

I am at a lost and can't seen to figure this out. Please help.

Sheet 1 (extraction sheet)

Sheet1

AB
NameCount
b
?
?

<COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: right"]2[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]
[TD="align: right"]200[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

</TBODY>

Spreadsheet Formulas
CellFormula
B2=SUMPRODUCT((Sheet2!$A$2:$A$5=$A2)+0)
A4{=IF(N($B2),IF(COLUMNS($A4:A4)<=$B2,INDEX(Sheet2!$B$2:$B$5,SMALL(IF(Sheet2!$A$2:$A$5=$A2,ROW(Sheet2!$A$2:$A$5)-ROW(Sheet2!$A$2)+1),COLUMNS($A4:A4))),""))}

<TBODY>
</TBODY>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<TBODY>
</TBODY>


Excel tables to the web >> Excel Jeanie HTML 4


Sheet 2 (data / source sheet)

Sheet2

AB
Name Tracking
a
b
b
c

<COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: right"]100[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: right"]200[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: right"]300[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="align: right"]400[/TD]

</TBODY>
There's no need to use this test in your formula:

=IF(N($B2)...

B2 is the result of the SUMPRODUCT formula which will always be a number (unless there may be errors in any of the referenced ranges).

If you index the entire column there's no need to calculate the row offset correction.

I assume you're entering the formula in cell A4 and copying across the row.

=IF(COLUMNS($A4:A4)>$B2,"",INDEX(Sheet2!$B:$B,SMALL(IF(Sheet2!$A$2:$A$5=$A2,ROW(Sheet2!$A$2:$A$5)),COLUMNS($A4:A4))))
 
Upvote 0
Excel 2010
AB

<tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FFFFFF"]Name[/TD]
[TD="bgcolor: #FFFFFF"]Count[/TD]

[TD="align: center"]2[/TD]
[TD="bgcolor: #FFFFFF"]a[/TD]
[TD="bgcolor: #FFFFFF, align: right"]100[/TD]

[TD="align: center"]3[/TD]
[TD="bgcolor: #FFFFFF"]b[/TD]
[TD="bgcolor: #FFFFFF, align: right"]200[/TD]

[TD="align: center"]4[/TD]
[TD="bgcolor: #FFFFFF"]b[/TD]
[TD="bgcolor: #FFFFFF, align: right"]300[/TD]

[TD="align: center"]5[/TD]
[TD="bgcolor: #FFFFFF"]c[/TD]
[TD="bgcolor: #FFFFFF, align: right"]400[/TD]

[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet2


Excel 2010
ABC
NameCount
Excel 07/10

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: center"]b[/TD]
[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: center"]200[/TD]
[TD="align: center"]200[/TD]

[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: center"]300[/TD]
[TD="align: center"]300[/TD]

[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]=COUNTIF(Sheet2!$A$2:$A$14,A2)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]B3[/TH]
[TD="align: left"]{=IF(ROWS($A$2:$A2)<=$B$2,INDEX(Sheet2!$B$2:$B$200,SMALL(IF(Sheet2!A$2:A$200=$A$2,ROW($A$2:$A$200)-ROW($A$2)+1),ROWS($A$2:A2))),"")}[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]C3[/TH]
[TD="align: left"]{=IFERROR(INDEX(Sheet2!$B$2:$B$200,SMALL(IF(Sheet2!A$2:A$200=$A$2,ROW($A$2:$A$200)-ROW($A$2)+1),ROWS($A$2:A2))),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]

Thankyou very much Robert and everyone else that took their time to reply.

Your formula is exactly what I needed. Thankyou very much guys for the quick response too! I'm certain that I will post more excel questions here and also answer some too, at least attempt to :P

Thanks again!
 
Upvote 0
Thankyou very much Robert and everyone else that took their time to reply.

Your formula is exactly what I needed. Thankyou very much guys for the quick response too! I'm certain that I will post more excel questions here and also answer some too, at least attempt to :P

Thanks again!

You are welcome.
Thanks for feedback.
 
Upvote 0

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