Matching based on rows

dhegs

New Member
Joined
May 6, 2021
Messages
6
Platform
  1. MacOS
Hi everyone,

I am looking to create a formula (I am assuming using Index & Match & IF??) that will provide me with a text output (for later use in Pivot Tables) to indicate this data should be removed.

As you can see in the picture, I've already got a column (column S) that refers to many different criteria (in hidden columns) to indicate this data should not be included. As you can see in column B, I have multiple data for each client and column T indicates the "first" and "last" row of this data.

What I am wanting, is to have a formula in column U that will indicate next to "first" and "last" for that client if it should be removed. For example for client 5502 the "first" data indicates it should be removed - I then want it to indicate in column U next to both "first" AND "last" that it should be removed. This will allow me to remove first and last data for this client in the Pivot Table as I can filter for the remove text in column U.

I am hoping someone might be able to help?!
 

Attachments

  • Screen Shot 2021-05-07 at 11.45.52 am.png
    Screen Shot 2021-05-07 at 11.45.52 am.png
    43.9 KB · Views: 17

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi, try this:
Book1
BSTU
1
25502REMOVEfirstREMOVE
35502 
45502 
55502 
65502 
75502 
85502 
95502 
105502REMOVElastREMOVE
115530first 
125530 
135530last 
141000first 
151000last 
162000REMOVEfirstREMOVE
172000 
182000 
192000 
202000lastREMOVE
213000first 
223000 
233000 
243000 
253000last 
Sheet1
Cell Formulas
RangeFormula
U2:U25U2=IF(ISBLANK(T2),"",IF(ISBLANK(VLOOKUP(B2,B:S,18,0)),"",VLOOKUP(B2,B:S,18,0)))
 
Upvote 0
Like this?

=IF(OR(COUNTIF(B$2:B2,B2)=COUNTIF(B:B,B2),COUNTIF(B$2:B2,B2)=1),"REMOVE","")
Thanks so much for your response, but no this doesn't work. This results in rows below (e.g. for client 556 in rows 13 & 14) saying that they should be removed.
 
Upvote 0
=IF(AND(COUNTIF(B:B,B2)=2,COUNTIF(B$2:B2,B2)=1),"",IF(OR(COUNTIF(B$2:B2,B2)=COUNTIF(B:B,B2),COUNTIF(B$2:B2,B2)=1),"REMOVE",""))

1620355501125.png
 
Upvote 0
Hi, try this:
Book1
BSTU
1
25502REMOVEfirstREMOVE
35502 
45502 
55502 
65502 
75502 
85502 
95502 
105502REMOVElastREMOVE
115530first 
125530 
135530last 
141000first 
151000last 
162000REMOVEfirstREMOVE
172000 
182000 
192000 
202000lastREMOVE
213000first 
223000 
233000 
243000 
253000last 
Sheet1
Cell Formulas
RangeFormula
U2:U25U2=IF(ISBLANK(T2),"",IF(ISBLANK(VLOOKUP(B2,B:S,18,0)),"",VLOOKUP(B2,B:S,18,0)))
Wow. Thanks so much. That works perfectly.
 
Upvote 0
Hi, try this:
Book1
BSTU
1
25502REMOVEfirstREMOVE
35502 
45502 
55502 
65502 
75502 
85502 
95502 
105502REMOVElastREMOVE
115530first 
125530 
135530last 
141000first 
151000last 
162000REMOVEfirstREMOVE
172000 
182000 
192000 
202000lastREMOVE
213000first 
223000 
233000 
243000 
253000last 
Sheet1
Cell Formulas
RangeFormula
U2:U25U2=IF(ISBLANK(T2),"",IF(ISBLANK(VLOOKUP(B2,B:S,18,0)),"",VLOOKUP(B2,B:S,18,0)))
Actually, sorry, I just noticed, this only works when the "first" has a corresponding "REMOVE". How can this be done if the "last" does but the first doesn't? I think it is so close!?
 
Upvote 0
Actually, sorry, I just noticed, this only works when the "first" has a corresponding "REMOVE". How can this be done if the "last" does but the first doesn't? I think it is so close!?
Oh, actually it changed everything :eek:, but this should do:
Book1
BSTU
25502REMOVEfirstREMOVE
35502 
45502 
55502 
65502lastREMOVE
75530firstREMOVE
85530 
95530REMOVElastREMOVE
101000first 
111000last 
122000REMOVEfirstREMOVE
132000 
142000 
152000 
162000lastREMOVE
173000first 
183000 
193000 
203000 
213000last 
Sheet1
Cell Formulas
RangeFormula
U2:U21U2=IF(AND(LEN(T2)>1,ISNUMBER(AGGREGATE(14,6,ROW($B$2:$B$21)/($B$2:$B$21=B2)/NOT(ISBLANK($S$2:$S$21)),1))),"REMOVE","")
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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