Formula Help Please

elleinndee

New Member
Joined
Jul 16, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello, I'm going crazy trying to figure out a formula. Any assistance is greatly appreciated.

On Sheet1 I have column A (Unique Identifier), column W (Authorization Date), column X (Start Date), and column Y (First Date Billed).

On Sheet 2 I have column B (Unique Identifier) and column I (Activity Date).

On Sheet 1 column Y is filled with the first Activity Date found (column I) on Sheet 2 via a VLOOKUP with the Unique Identifier (column A on Sheet 1, column B on Sheet 2).

I need a formula for column X on Sheet 1, Start Date, that will give me this:

If on Sheet 1 column W (Authorization Date) comes before column Y (First Date Billed), the Unique Identifier on both sheets is used to lookup the nearest date after Sheet 2 column I (Activity Date) which will then fill column X (Start Date) on Sheet 1.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
column Y is filled with the first Activity Date found
For any given Unique Identifier in column A of Sheet 1, will there ever only be one match found in column B of Sheet 2?...or could there be multiple entries in col. B of Sheet 2 that have the same Unique Identifier? Your use of the phrase "first Activity Date found" makes me curious about this, as if there could be 2nd, 3rd, etc. matches as well.

On Sheet 2, are the Unique Identifiers in column B always listed in ascending order? You mention using a VLOOKUP function; and depending on how it is used, sort order may matter.

If on Sheet 1 column W (Authorization Date) comes before column Y (First Date Billed), the Unique Identifier on both sheets is used to lookup the nearest date after Sheet 2 column I (Activity Date) which will then fill column X (Start Date) on Sheet 1.
Could you clarify this further, please? You obtain the First Date Billed (col Y Sheet 1) by matching Unique Identifiers to obtain the "first" match in column B Sheet 2 and extract the corresponding Activity Date (col I Sheet 2)...that's the First Date Billed. Then you want a comparison...IF ([Authorization Date]<[First Date Billed], "Unique Identifiers used to lookup nearest date after Sheet 2 column I"...what does this last part mean? Suppose [Authorization Date]<[First Date Billed], we look at the corresponding Unique Identifier on that row in Sheet 1 and then what?...we find that Unique Identifier in column B of Sheet 2 and...? are there multiple matching Unique Identifiers on Sheet 2 and we obtain a different Activity Date? This is what I'm confused about.
 
Upvote 0
For any given Unique Identifier in column A of Sheet 1, will there ever only be one match found in column B of Sheet 2?...or could there be multiple entries in col. B of Sheet 2 that have the same Unique Identifier?
There are multiple entries.
Your use of the phrase "first Activity Date found" makes me curious about this, as if there could be 2nd, 3rd, etc. matches as well.
Yes, there can be multiple Activity Dates. This column is sorted in ascending order so the first match found is the one pulled.

On Sheet 2, are the Unique Identifiers in column B always listed in ascending order? You mention using a VLOOKUP function; and depending on how it is used, sort order may matter.
No, only the activity date column on sheet 2 is listed in ascending order.
Could you clarify this further, please? You obtain the First Date Billed (col Y Sheet 1) by matching Unique Identifiers to obtain the "first" match in column B Sheet 2 and extract the corresponding Activity Date (col I Sheet 2)...that's the First Date Billed.
Correct. Column I sheet 2 is sorted in ascending order so it gives us the earliest date that way.
Then you want a comparison...IF ([Authorization Date]<[First Date Billed], "Unique Identifiers used to lookup nearest date after Sheet 2 column I"...what does this last part mean? Suppose [Authorization Date]<[First Date Billed], we look at the corresponding Unique Identifier on that row in Sheet 1 and then what?...we find that Unique Identifier in column B of Sheet 2 and...? are there multiple matching Unique Identifiers on Sheet 2 and we obtain a different Activity Date?
Yes. We want to find the nearest activity date date to the authorization date. So if the authorization date is 7/1/2022 and the first date billed is 6/1/2022, we want to find the activity date that is greater than or equal to the authorization date, so 7/3/2022 for example.
This is what I'm confused about.

Thank you for responding! Sorry for the difficult wording. I would attach but the sheet has confidential client information.
 
Upvote 0
Are the Authorization Dates "given"...that is, you already know them? So would it make for sense to simply use both the Unique Identifier from col A/Sht 1 and Authorization Date from col W/Sht 1 and find the next larger Activity Date associated with that Unique Identifier on Sheet 2? Would that work in all cases?
 
Upvote 0
Are the Authorization Dates "given"...that is, you already know them? So would it make for sense to simply use both the Unique Identifier from col A/Sht 1 and Authorization Date from col W/Sht 1 and find the next larger Activity Date associated with that Unique Identifier on Sheet 2? Would that work in all cases?
Yes all the authorization dates are given. Yes what you are saying would work and sounds so much simpler. My brain just can’t work out how to do that though?
 
Upvote 0
Try this:
Book2
AWXY
1Unique IdentifierAuthorization DateStart DateFirst Date Billed
2uid11/10/20221/15/20221/7/2022
3uid21/20/20221/23/20221/23/2022
4uid31/15/2022no date foundno date found
5uid43/3/20224/17/20221/8/2022
6uid52/5/20222/8/20222/8/2022
7uid64/13/2022no date foundno date found
8uid74/20/2022no date foundno date found
9uid86/17/20227/11/20227/11/2022
Sheet1
Cell Formulas
RangeFormula
X2:X9X2=IFERROR(INDEX(SORT(FILTER(Sheet2!$I$2:$I$10,(Sheet2!$B$2:$B$10=$A2)*(Sheet2!$I$2:$I$10>$W2))),1),"no date found")
Y2:Y9Y2=IFERROR(INDEX(SORT(FILTER(Sheet2!$I$2:$I$10,(Sheet2!$B$2:$B$10=$A2))),1),"no date found")

For this notional data set:
Book2
BI
1Unique IdentifierActivity Date
2uid11/7/2022
3uid41/8/2022
4uid11/15/2022
5uid21/23/2022
6uid52/8/2022
7uid42/13/2022
8uid44/17/2022
9uid15/15/2022
10uid87/11/2022
Sheet2

Sorting of your table is not required as the formula handles that.
 
Upvote 0
Solution
Try this:
Book2
AWXY
1Unique IdentifierAuthorization DateStart DateFirst Date Billed
2uid11/10/20221/15/20221/7/2022
3uid21/20/20221/23/20221/23/2022
4uid31/15/2022no date foundno date found
5uid43/3/20224/17/20221/8/2022
6uid52/5/20222/8/20222/8/2022
7uid64/13/2022no date foundno date found
8uid74/20/2022no date foundno date found
9uid86/17/20227/11/20227/11/2022
Sheet1
Cell Formulas
RangeFormula
X2:X9X2=IFERROR(INDEX(SORT(FILTER(Sheet2!$I$2:$I$10,(Sheet2!$B$2:$B$10=$A2)*(Sheet2!$I$2:$I$10>$W2))),1),"no date found")
Y2:Y9Y2=IFERROR(INDEX(SORT(FILTER(Sheet2!$I$2:$I$10,(Sheet2!$B$2:$B$10=$A2))),1),"no date found")

For this notional data set:
Book2
BI
1Unique IdentifierActivity Date
2uid11/7/2022
3uid41/8/2022
4uid11/15/2022
5uid21/23/2022
6uid52/8/2022
7uid42/13/2022
8uid44/17/2022
9uid15/15/2022
10uid87/11/2022
Sheet2

Sorting of your table is not required as the formula handles that.
Yes!!! Thank you so much! You've saved the day!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

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