Urgent need for help: Extracting data to a new spreadsheet based on one criteria but multiple matches

ReaRaeS

New Member
Joined
Mar 27, 2019
Messages
6
I have a daily sales spreadsheet that is added to daily. It is everything that is sold from 1/1 to 12/31 each year. It lists salespeople and items sold etc. I need to create a spreadsheet for each salesperson monthly to track their commissions for the month.
I have pulled that spreadsheet in to a second one with the columns I need by simply doing an = function and then delete the sales I do not need to calculate commissions on.

On my next spreadsheet (one for each salesperson) I am trying to pull their info to the new spreadsheet. The one I am pulling from has data from columns A - R. I only need the data from C - R with a few columns left out on the new spreadsheet, but I need all sales for that specific salesperson so I can't use Vlookup. I am trying this formula:
=IFERROR(INDEX('Daily Sales'!$C$2:$R$8150,SMALL(IF('Daily Sales'!$P$2:$P$8150=$B$1,ROW(INDIRECT("1:"&ROWS('Daily Sales'!$C$2:$C$8150)))),ROW(A1)),1),"")

Unfortunately, I am getting the first row of data in the spreadsheet that does not belong to the salesperson's number in B1 and in the following rows just blanks when the formula is copied down. I am guessing that my problem is somewhere in the Indirect formula but I have no idea what I should be using.

My original table (Tab: Daily Sales) has headers in row 1 and currently data in rows from 2 - 8150 and columns C - R. The salesperson's number is in column P. My new table (tab: 201 - Dave Brown) has the salesman # in B1 and the header info in row 4 with data to be in rows 5 - 500 or however are necessary to meet the sales for the month for each salesperson and columns A - J. The data in each of the columns is correct in that it came from the correct column on the original spreadsheet, just the wrong line(row).

Can someone please assist me in correcting this formula or help me with a new one so it grabs the correct rows.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
it's actually better to post a small sample of the data and desired results.
 
Upvote 0
Example of Original Sheet

'Daily Sales'
[TABLE="width: 1698"]
<tbody>[TR]
[TD][/TD]
[TD]C =1[/TD]
[TD]D =2[/TD]
[TD]E =3[/TD]
[TD]F =4[/TD]
[TD]G = 5[/TD]
[TD]H = 6[/TD]
[TD]I = 7[/TD]
[TD]J =8[/TD]
[TD]K = 9[/TD]
[TD]L= 10[/TD]
[TD]M = 11[/TD]
[TD]N = 12[/TD]
[TD]O =13[/TD]
[TD]P = 14[/TD]
[TD]Q =15[/TD]
[TD]R =16[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Invoice Date[/TD]
[TD]Area[/TD]
[TD]Class[/TD]
[TD]Customer #[/TD]
[TD]Name[/TD]
[TD]Invoice Number[/TD]
[TD]Item[/TD]
[TD]QTY[/TD]
[TD]City[/TD]
[TD]State[/TD]
[TD]Zip[/TD]
[TD]Zip 3[/TD]
[TD]Branch[/TD]
[TD]Sales Person[/TD]
[TD] Sales man[/TD]
[TD] Net sales value[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3/1/2019[/TD]
[TD]DR[/TD]
[TD]OPTR[/TD]
[TD="align: right"]1007243[/TD]
[TD]St Agnes Medical Center[/TD]
[TD="align: right"]496236[/TD]
[TD]51-850-7.75MM[/TD]
[TD="align: right"]1[/TD]
[TD] Fresno[/TD]
[TD]CA[/TD]
[TD="align: right"]93720[/TD]
[TD] 937[/TD]
[TD]C[/TD]
[TD="align: right"]203[/TD]
[TD] KLM[/TD]
[TD] $ 79.00

[/TD]
[/TR]
</tbody>[/TABLE]

Results on second sheet:

'201 - Dave Brown'
[TABLE="width: 940"]
<tbody>[TR]
[TD][/TD]
[TD]A = 1[/TD]
[TD]B = 4[/TD]
[TD]C = 5[/TD]
[TD]D = 6[/TD]
[TD]E = 7[/TD]
[TD]F = 8[/TD]
[TD]G=9[/TD]
[TD]H = 10[/TD]
[TD]I = 11[/TD]
[TD]J = 16[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Salesperson:[/TD]
[TD]201[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Invoice Date[/TD]
[TD]Customer #[/TD]
[TD]Name[/TD]
[TD]Invoice Number[/TD]
[TD]Item[/TD]
[TD]QTY[/TD]
[TD]City[/TD]
[TD]State[/TD]
[TD]Zip[/TD]
[TD] Net sales value[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]3/4/2019[/TD]
[TD="align: right"]2500049[/TD]
[TD] Green Valley Surgery Center[/TD]
[TD="align: right"]496316[/TD]
[TD] 51-835-7.00MM[/TD]
[TD="align: right"]1[/TD]
[TD]Las Vegas[/TD]
[TD]NV[/TD]
[TD="align: right"]89120[/TD]
[TD="align: right"]75[/TD]
[/TR]
</tbody>[/TABLE]


Again, here is my formula in cell A5:
=IFERROR(INDEX('Daily Sales'!$C$2:$R$8023,SMALL(IF('Daily Sales'!$P$2:$P$8023=$B$1,ROW(INDIRECT("1:'Daily Sales'!"&ROWS('Daily Sales'!$C$2:$C$8023)))),ROW(A1)),1),"")

The results correspond to row 5 on the original spreadsheet and do not match the salesperson number in row P.
 
Upvote 0
I've amend your formula and data for testing, note that Formula in A5 (copy across and down) is a array formula.


Book1
CDEFGHIJKLMNOPQR
1Invoice DateAreaClassCustomer #NameInvoice NumberItemQTYCityStateZipZip 3BranchSales PersonSales manNet sales value
203/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM1FresnoCA93720937C203KLM100
331/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM2FresnoCA93720937C203KLM200
409/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM3FresnoCA93720937C201KLM300
520/12/2018DROPTR1007243St Agnes Medical Center49623651-850-7.75MM4FresnoCA93720937C203KLM400
630/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM5FresnoCA93720937C203KLM500
719/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM6FresnoCA93720937C201KLM600
831/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM7FresnoCA93720937C203KLM700
901/02/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM8FresnoCA93720937C203KLM800
1001/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM9FresnoCA93720937C201KLM900
1120/01/2019DROPTR1007243St Agnes Medical Center49623651-850-7.75MM10FresnoCA93720937C203KLM1000
Daily Sales



Book1
ABCDEFGHIJ
1Salesperson:203
2
3
4Invoice DateCustomer #NameInvoice NumberItemQTYCityStateZipNet sales value
503/01/20191007243St Agnes Medical Center49623651-850-7.75MM1FresnoCA93720100
631/01/20191007243St Agnes Medical Center49623651-850-7.75MM2FresnoCA93720200
720/12/20181007243St Agnes Medical Center49623651-850-7.75MM4FresnoCA93720400
201 - Dave Brown
Cell Formulas
RangeFormula
A5{=IFERROR(INDEX('Daily Sales'!$C$2:$R$8150,SMALL(IF('Daily Sales'!$P$2:$P$8150=$B$1,ROW(INDIRECT("1:"&ROWS('Daily Sales'!$C$2:$C$8150)))),ROW(A1)),MATCH(A$4,'Daily Sales'!$C$1:$R$1,0)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,918
Messages
6,181,743
Members
453,064
Latest member
robatthe2A

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