Possible IF formula

Rachelpan

New Member
Joined
Jan 29, 2020
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
I have 5 columns of data in sheet 1.
Column A contains dept
Column B contains codes
Column C D E contain numerical data

I would like to know how I can auto extract only certain codes from each department along with their corresponding numerical data - and have it auto fill similar columns in sheet 2.
For purposes of this question I have put the sheet 2 column headings also in sheet 1.

For example I would like to only export the codes H and W - with dept and corresponding data-from each department and have only that placed into the other columns - leaving no blank cells in between. I have provided what it looks like on the sheet.

And would like this to be automatic every time new data is put into sheet 1.



book 1.png
 
I would prefer a formula that does the job.
In that case try something like this on Sheet2. Codes of interest are listed in column H.

The formula in A2 is copied across to column E and down as far as you might ever need after first adjusting (if required) the $10000 figure that I have used to ensure the range is big enough to cover any potential amount of data that could occur in your Sheet1. You mentioned possibly 50 departments with 100 or more codes per department which might give around 5000 rows so I allowed about double just in case.

Simply change the codes in column H and the results should automatically update.

Rachelpan.xlsm
ABCDEFGH
1Deptcodetime cotme jbdollarsCodes of interest
21A105100A
31B1510200B
42A105100
52B1510200
63A105100
73B1510200
84A105100
94B1510200
105A105100
115B1510200
12     
13     
Sheet2
Cell Formulas
RangeFormula
A2:E13A2=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!A$1:A$10000)/ISNUMBER(MATCH(Sheet1!$B$1:$B$10000,$H:$H,0)),ROWS(A$2:A2))),"")
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
In that case try something like this on Sheet2. Codes of interest are listed in column H.

The formula in A2 is copied across to column E and down as far as you might ever need after first adjusting (if required) the $10000 figure that I have used to ensure the range is big enough to cover any potential amount of data that could occur in your Sheet1. You mentioned possibly 50 departments with 100 or more codes per department which might give around 5000 rows so I allowed about double just in case.

Simply change the codes in column H and the results should automatically update.

Rachelpan.xlsm
ABCDEFGH
1Deptcodetime cotme jbdollarsCodes of interest
21A105100A
31B1510200B
42A105100
52B1510200
63A105100
73B1510200
84A105100
94B1510200
105A105100
115B1510200
12     
13     
Sheet2
Cell Formulas
RangeFormula
A2:E13A2=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!A$1:A$10000)/ISNUMBER(MATCH(Sheet1!$B$1:$B$10000,$H:$H,0)),ROWS(A$2:A2))),"")

In that case try something like this on Sheet2. Codes of interest are listed in column H.

The formula in A2 is copied across to column E and down as far as you might ever need after first adjusting (if required) the $10000 figure that I have used to ensure the range is big enough to cover any potential amount of data that could occur in your Sheet1. You mentioned possibly 50 departments with 100 or more codes per department which might give around 5000 rows so I allowed about double just in case.

Simply change the codes in column H and the results should automatically update.

Rachelpan.xlsm
ABCDEFGH
1Deptcodetime cotme jbdollarsCodes of interest
21A105100A
31B1510200B
42A105100
52B1510200
63A105100
73B1510200
84A105100
94B1510200
105A105100
115B1510200
12     
13     
Sheet2
Cell Formulas
RangeFormula
A2:E13A2=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!A$1:A$10000)/ISNUMBER(MATCH(Sheet1!$B$1:$B$10000,$H:$H,0)),ROWS(A$2:A2))),"")
Peter
This was SUPERB!
Many Thanks!!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,264
Members
449,075
Latest member
staticfluids

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