SOLVED
Home

Return filtered column data from one sheet to another

%3CLINGO-SUB%20id%3D%22lingo-sub-916399%22%20slang%3D%22en-US%22%3EReturn%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-916399%22%20slang%3D%22en-US%22%3E%3CP%3EHi!%20I%20have%20a%20sheet%20called%26nbsp%3B%3CSTRONG%3EEmployees%3C%2FSTRONG%3E%20with%203%20columns%3A%3C%2FP%3E%3CUL%3E%3CLI%3EID%3C%2FLI%3E%3CLI%3EName%3C%2FLI%3E%3CLI%3EWork%20Status%20(Active%2C%20Inactive)%3C%2FLI%3E%3C%2FUL%3E%3CTABLE%20border%3D%221%22%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CSTRONG%3EID%3C%2FSTRONG%3E%3C%2FTD%3E%3CTD%3E%3CSTRONG%3EName%3C%2FSTRONG%3E%3C%2FTD%3E%3CTD%3E%3CSTRONG%3EWork%20Status%3C%2FSTRONG%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E001%3C%2FTD%3E%3CTD%3EAbigail%3C%2FTD%3E%3CTD%3EActive%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E002%3C%2FTD%3E%3CTD%3EBrian%3C%2FTD%3E%3CTD%3EActive%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E003%3C%2FTD%3E%3CTD%3EGrace%3C%2FTD%3E%3CTD%3EInactive%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20like%20to%20filter%20active%20employees%20and%20send%20them%20over%20to%20another%20sheet%20called%26nbsp%3B%3CSTRONG%3EPayroll%3C%2FSTRONG%3E%2C%20which%20fills%202%20columns%3A%3C%2FP%3E%3CUL%3E%3CLI%3EEmployee%20ID%3C%2FLI%3E%3CLI%3EEmployee%20Name%3C%2FLI%3E%3C%2FUL%3E%3CTABLE%20border%3D%221%22%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CSTRONG%3EEmployee%20ID%3C%2FSTRONG%3E%3C%2FTD%3E%3CTD%3E%3CSTRONG%3EEmployee%20Name%3C%2FSTRONG%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E001%3C%2FTD%3E%3CTD%3EAbigail%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E002%3C%2FTD%3E%3CTD%3EBrian%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20read%20multiple%20forums%20and%20they%20all%20provide%20a%20solution%20that%20combines%20IFERRORS%2C%20INDEX%2C%20SMALL%2C%20and%20ROW%20functions.%20However%2C%20I%20don't%20understand%20entirely%20how%20it%20works%20and%20haven't%20been%20able%20to%20use%20them%20on%20my%20data%20set.%20I'm%20attaching%20an%20example%20workbook.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-916399%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-916416%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-916416%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F426976%22%20target%3D%22_blank%22%3E%40emilioramirezz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20attached%20version%20of%20your%20file%2C%20the%20formula%20in%20A2%20is%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DIFERROR(INDEX(Employees!A%242%3AA%2411%2C%3CBR%20%2F%3EAGGREGATE(15%2C6%2CEmployees!A%242%3AA%2411%2F(Employees!C%242%3AC%2411%3D%22Active%22)%2C%3CBR%20%2F%3EROW()-1))%2C%22%22)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EMeanwhile%2C%20the%20formula%20in%20B2%20is%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DIF(A2%3D%22%22%2C%22%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3ELOOKUP(A2%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EEmployees!A%242%3AB%2411))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThe%20result%20of%20the%20foregoing%20formulas%20is%20this%3A%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20341px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137814i4B583EC8D750D1CE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Active%20Employees.PNG%22%20title%3D%22Active%20Employees.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-917214%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917214%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%2C%20that%20worked%20great!%20I%20just%20have%20a%20couple%20of%20questions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EI%20don't%20understand%20what%20the%20SMALL%20function%2C%20applied%20through%20AGGREGATE%2C%20is%20doing.%20What%20is%20the%20division%26nbsp%3B%3CSTRONG%3EEmployees!A%242%3AA%2411%2F(Employees!C%242%3AC%2411%3D%22Active%22)%3C%2FSTRONG%3E%20doing%20and%20%3CSTRONG%3EROW()-1%3C%2FSTRONG%3E%3F%26nbsp%3BCould%20you%20explain%20it%20to%20me%20a%20little%20bit%20further%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EIs%20there%20a%20way%20to%20avoid%20having%20to%20manually%20edit%20the%20formula%20to%20include%20future%20employees%20added%20to%20the%20Employees%20sheet%3F%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-917290%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917290%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F426976%22%20target%3D%22_blank%22%3E%40emilioramirezz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20make%20the%20ranges%20in%20both%20sheets%20dynamic%2C%20I%20converted%20them%20to%20Table%20(by%20selecting%20a%20cell%20therein%20and%20pressing%20Ctrl%2BT).%20The%20new%20formula%20in%20A2%20is%20now%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DIFERROR(INDEX(EmployeeTable%5BID%5D%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EAGGREGATE(15%2C6%2CEmployeeTable%5BID%5D%2F(EmployeeTable%5BWork%20Status%5D%3D%22Active%22)%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EROW()-1))%2C%22%22)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EAlso%2C%20the%20new%20formula%20in%20B2%20is%20now%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DIF(%5BEmployee%20ID%5D%3D%22%22%2C%22%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3ELOOKUP(%5BEmployee%20ID%5D%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3EEmployeeTable%5BID%5D%3AEmployeeTable%5BName%5D))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThe%20result%20of%20the%20foregoing%20formulas%20is%20now%20this%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20328px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F138118i2E6D8CE4E6381896%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Active%20EmployeesV1.0.PNG%22%20title%3D%22Active%20EmployeesV1.0.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIn%20the%20formula%20in%20A2%2C%26nbsp%3B%3CSTRONG%3EEmployeeTable%5BID%5D%2F(EmployeeTable%5BWork%20Status%5D%3D%22Active%22)%3C%2FSTRONG%3E%20creates%20this%20array%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%7B1%3B2%3B%23DIV%2F0!%3B4%3B%23DIV%2F0!%3B%23DIV%2F0!%3B%23DIV%2F0!%3B8%3B9%3B%23DIV%2F0!%7D%3C%2FP%3E%3CP%3EIn%20the%20options%20argument%20of%20AGGREGATE%2C%206%20ignores%20the%20%23DIV%2F0%20errors%20in%20the%20foregoing%20array.%20ROW()-1%20evaluates%20to%201%2C%20and%20increases%20to%202%2C%203%2C%20and%20so%20forth%20as%20the%20formula%20is%20copied%20down%20the%20rows.%20Thus%2C%20AGGREGATE%20returns%20the%201st%20smallest%2C%202nd%20smallest%2C%203rd%20smallest%2C%20and%20so%20forth.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-917340%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917340%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3Bthanks%20for%20explaining.%20I%20have%20a%20better%20understanding%20of%20what%20the%20formula%20is%20doing%20now.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20seem%20to%20be%20having%20a%20problem%20with%20the%20A2%20formula.%20I%20noticed%20this%20before%20and%20after%20converting%20the%20data%20to%20Table.%20The%20result%20brings%20most%20of%20the%20correct%20active%20workers%20but%20omits%20some%20of%20them%20and%20replaces%20them%20with%20inactive%20workers.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20attaching%20the%20workbook%20with%20cells%20that%20contain%20an%20error%20highlighted%20in%20red.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-917376%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20filtered%20column%20data%20from%20one%20sheet%20to%20another%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917376%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F426976%22%20target%3D%22_blank%22%3E%40emilioramirezz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20anyone%20has%20a%20similar%20problem%20and%20is%20working%20within%20an%20Office%20365%20environment%2C%20a%20simple%20solution%20now%20exists.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20assumed%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E's%20use%20of%20a%20table%20for%20the%20source%20data%20to%20make%20the%20data%20dynamic%20but%20I%20returned%20the%20output%20table%20to%20a%20range.%26nbsp%3B%20The%20formula%20is%20written%20into%20a%20single%20cell%20%3CSPAN%3Eof%20the%20payroll%20sheet%3C%2FSPAN%3E%20(A2%20for%20example)%20and%20will%20spill%20into%20adjacent%20cells%20to%20pull%20all%20the%20required%20information%20forward.%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3D%20FILTER(EmployeeTable%5B%5BID%5D%3A%5BName%5D%5D%2C%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3EEmployeeTable%5BWork%20Status%5D%3D%22Active%22)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CFONT%3ESomething%20to%20bear%20in%20mind%20is%20that%20the%20payroll%20list%20is%20dynamic%20so%20a%20given%20employee%20will%20not%20always%20appear%20on%20the%20same%20row.%26nbsp%3B%20This%20means%20that%20any%20further%20fields%20need%20to%20be%20populated%20by%20looking%20up%20by%20the%20employee%20ID%20rather%20than%20typing%20directly%20into%20the%20worksheet.%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
emilioramirezz
Occasional Contributor

Hi! I have a sheet called Employees with 3 columns:

  • ID
  • Name
  • Work Status (Active, Inactive)
IDNameWork Status
001AbigailActive
002BrianActive
003GraceInactive

 

I'd like to filter active employees and send them over to another sheet called Payroll, which fills 2 columns:

  • Employee ID
  • Employee Name
Employee IDEmployee Name
001Abigail
002Brian

 

I've read multiple forums and they all provide formulas that combine IFERROR, INDEX, SMALL, and ROW functions. Unfortunately, I don't understand entirely how their formulas work, so I haven't been able to use them on my data set. I'm attaching an example workbook.

10 Replies
Solution

@emilioramirezz 

In the attached version of your file, the formula in A2 is: 

=IFERROR(INDEX(Employees!A$2:A$11,
AGGREGATE(15,6,Employees!A$2:A$11/(Employees!C$2:C$11="Active"),
ROW()-1)),"")

Meanwhile, the formula in B2 is: 

=IF(A2="","",
LOOKUP(A2,
Employees!A$2:B$11))

The result of the foregoing formulas is this: 

 
 
 
 

Active Employees.PNG

Thanks @Twifoo, that worked great! I just have a couple of questions.

 

  • I don't understand what the SMALL function, applied through AGGREGATE, is doing. What is the division Employees!A$2:A$11/(Employees!C$2:C$11="Active") doing and ROW()-1? Could you explain it to me a little bit further?

 

  • Is there a way to avoid having to manually edit the formula to include future employees added to the Employees sheet? 

 

@emilioramirezz 

To make the ranges in both sheets dynamic, I converted them to Table (by selecting a cell therein and pressing Ctrl+T). The new formula in A2 is now: 

=IFERROR(INDEX(EmployeeTable[ID],
AGGREGATE(15,6,EmployeeTable[ID]/(EmployeeTable[Work Status]="Active"),
ROW()-1)),"")

Also, the new formula in B2 is now: 

=IF([Employee ID]="","",
LOOKUP([Employee ID],
EmployeeTable[ID]:EmployeeTable[Name]))

The result of the foregoing formulas is now this: 

Active EmployeesV1.0.PNG

In the formula in A2, EmployeeTable[ID]/(EmployeeTable[Work Status]="Active") creates this array: 

{1;2;#DIV/0!;4;#DIV/0!;#DIV/0!;#DIV/0!;8;9;#DIV/0!}

In the options argument of AGGREGATE, 6 ignores the #DIV/0 errors in the foregoing array. ROW()-1 evaluates to 1, and increases to 2, 3, and so forth as the formula is copied down the rows. Thus, AGGREGATE returns the 1st smallest, 2nd smallest, 3rd smallest, and so forth. 

@Twifoo thanks for explaining. I have a better understanding of what the formula is doing now.

 

I seem to be having a problem with the A2 formula. I noticed this before and after converting the data to Table. The result brings most of the correct active workers but omits some of them and replaces them with inactive workers.

 

I'm attaching the workbook with cells that contain an error highlighted in red.

@emilioramirezz 

If anyone has a similar problem and is working within an Office 365 environment, a simple solution now exists. 

 

I have assumed @Twifoo's use of a table for the source data to make the data dynamic but I returned the output table to a range.  The formula is written into a single cell of the payroll sheet (A2 for example) and will spill into adjacent cells to pull all the required information forward.

= FILTER(EmployeeTable[[ID]:[Name]],

EmployeeTable[Work Status]="Active")

Something to bear in mind is that the payroll list is dynamic so a given employee will not always appear on the same row.  This means that any further fields need to be populated by looking up by the employee ID rather than typing directly into the worksheet.

@emilioramirezz 

Employee number 108 is missing producing a mismatch between row numbers and employee IDs.

@emilioramirezz 

I assumed that the Employee ID's were consecutive. Now, I noticed that Employee ID 108 and 184 were missing. In the attached version of the file, I modified the formula in A2 to this: 

=IFERROR(INDEX(EmployeeTable[ID],
AGGREGATE(15,6,ROW(EmployeeTable[ID])/(EmployeeTable[Work Status]="Active")-1,
ROW()-1)),"")

Thanks @Peter Bartholomew. The FILTER function seems really useful; unfortunately, my version of Excel doesn't support it. I'll keep it in mind if Microsoft rolls it out to every user.

Thanks @Twifoo. They are supposed to be consecutive. I made a mistake and missed those two missing rows.

 

Thanks for helping me solve this problem.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies