Need to find data within a specified range when there are multiple ranges with similar data

LoganAltsEval

New Member
Joined
Dec 27, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet of payroll data from a payroll provider. The data has each employee's name and then specific payroll info (such as gross pay, employer taxes, employee taxes, etc.) in multiple columns to the right of each person. Sometimes the order of the employees stays the same and other times it changes (i.e. an employee is added or removed). The data in the columns may also change based on specific items related to that employee in a given pay period. For example, one pay period they may have mileage reimbursement but the next pay period they do not.

I would like to write a formula that identifies the employee listed in column A, then finds the specific type of info I am looking for (such as total taxes), then returns the amount in the cell immediately to the right of that info. For example, in the attached screenshot (names changed to protect privacy), the formula would first search column A for "Sweat, Bill", then it would search his payroll info to the right (cells A13:S23) for the words "Total Taxes" (in merged cell I22), then it would return the value of 515.67 (in merged cell J22). Is there a formula for this?

Note that this info is downloaded from our payroll provider, pasted into another spreadsheet that has additional tabs and linked formulas, and is utilized by my staff who are not proficient with Excel, so I do not have the flexibility or desire to change the formatting of the info.
 

Attachments

  • Payroll Sample Spreadsheet.png
    Payroll Sample Spreadsheet.png
    37.8 KB · Views: 17

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Here is an abbreviated source table:
MrExcel_20231228.xlsx
ABCDEFGHIJ
1Doe, John
2
3
4
5Med1.11
6
7
8
9
10Total Earnings1Total Taxes2
11
12
13Sweat, Bill
14
15
16SS2.22
17
18
19
20
21
22Total Earnings3Total Taxes4
23
24
25Williams, Jane
26
Sheet1

...and an idea for extracting the value of interest:
MrExcel_20231228.xlsx
ABC
1
2Sweat, BillTotal Taxes4
3Doe, JohnMed1.11
4Sweat, BillSS2.22
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=LET(ur,MATCH(A2,Sheet1!$A$1:$A$1000,0),lr,MATCH("Total Earnings",INDEX(Sheet1!D:D,ur+1):Sheet1!D1000,0)+ur+1,rng,INDEX(Sheet1!A:A,ur):INDEX(Sheet1!S:S,lr),rng2col,TOCOL(rng),INDEX(rng2col,MATCH(B2,rng2col,0)+1))

This method assumes the words "Total Earnings" in column D can be used to identify the bottom of a person's information block. I'm not sure whether the merged cells (generally a bad idea) will cause any problems, so test carefully.
 
Upvote 0
Solution
Same idea with a slightly shorter formula (in col D) for creating the range to be searched:
MrExcel_20231228.xlsx
ABCD
2Sweat, BillTotal Taxes44
Sheet2
Cell Formulas
RangeFormula
C2C2=LET(ur,MATCH(A2,Sheet1!$A$1:$A$1000,0),lr,MATCH("Total Earnings",INDEX(Sheet1!D:D,ur+1):Sheet1!D1000,0)+ur+1,rng,INDEX(Sheet1!A:A,ur):INDEX(Sheet1!S:S,lr),rng2col,TOCOL(rng),INDEX(rng2col,MATCH(B2,rng2col,0)+1))
D2D2=LET(ur,MATCH(A2,Sheet1!$A$1:$A$1000,0),lr,MATCH("Total Earnings",DROP(Sheet1!D:D,ur-1),0)+ur,rng,TAKE(DROP(Sheet1!A:S,ur-1),lr-ur+1),rng2col,TOCOL(rng),INDEX(rng2col,MATCH(B2,rng2col,0)+1))
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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