Search code examples
exceltimeexcel-formulaautomationlookup

Automation in Excel for shift patterns


Hi I have the following two tables

enter image description here

I am trying to get the col

I am trying to automate Column E so that every time the data changes in cell D2 it would automatically get changed based on the shift patter that the Agent is assigned on that day.

I cannot used vlookup because it will obviously just take the first text found with for example 9am-5pm - all cells would be populated with Agent 3.


Solution

  • Seems like this array formula in E3 in part does what you want (it is entered not using usual Enter key, but instead, Ctrl + Shift + Enter).

    =INDEX($A$2:$A$10,SMALL(IF(D3=$B$2:$B$10,ROW($B$2:$B$10)-ROW($B$2)+1),COUNTIF($D$3:D3,D3)))
    

    enter image description here