Return Each First and Last Instance of a Value in a Range

Lance1227

New Member
Joined
Mar 27, 2023
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to return the first and last instances of a value, but the issue I'm having is that there may be multiple instances of the value in the range and I need each occurrence results displayed separately. The range is for a monthly timecard and the value is time off for vacation. I'm trying to return the first and last day of each occurrence of consecutive days. So in the attached file, the first three days tagged "VL" would return the dates 4 Jan 23 in one cell and 6 Jan 23 in the next cell. Then it would go to the next occurrence and again return first and last dates. I'm seeing how to get the first and last occurrence, but it's the multiple occurrences that has me stumped. Any assistance would be most appreciated.
 

Attachments

  • Timecard VL.JPG
    Timecard VL.JPG
    47.5 KB · Views: 12
  • Timecard VL Results.JPG
    Timecard VL Results.JPG
    17 KB · Views: 13
See if this is headed in the right direction.

Lance1227.xlsm
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1SunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTue
201020304050607080910111213141516171819202122232425262728293031
30888880088888008888800888880088
42AL8AL8SLM3SL8HP8SML2CMCL
51ND
6
7
8AL102/01/20233/01/2023
9SLM86/01/20236/01/2023
10SL38/01/20238/01/2023
11HP811/01/202311/01/2023
12ND111/01/202311/01/2023
13SML813/01/202313/01/2023
14CMCL217/01/202317/01/2023
Sheet2
Cell Formulas
RangeFormula
F8:F14F8=SUMPRODUCT(--(RIGHT(D$4:AH$5,LEN(E8))=E8),IFERROR(SUBSTITUTE($D$4:$AH$5,E8,"")+0,0))
G8:G14G8=IF(F8=0,"",AGGREGATE(15,6,D$2:AH$2/((RIGHT(D$4:AH$5,LEN(E8))=E8)*(ISNUMBER(MID(D$4:AH$6,LEN(D$4:AH$5)-LEN(E8),1)+0))),1))
H8:H14H8=IF(F8=0,"",AGGREGATE(14,6,D$2:AH$2/((RIGHT(D$4:AH$5,LEN(E8))=E8)*(ISNUMBER(MID(D$4:AH$5,LEN(D$4:AH$5)-LEN(E8),1)+0))),1))


I was wondering what result(s) you would want for a situation like this though?

Lance1227.xlsm
EFGHI
1MonTueWedThuFri
20203040506
388888
42AL8AL8SLM4AL
5
Sheet3
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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