How can i get all dates on which employee was on shift A from attendance sheet

Sakshine

New Member
Joined
Aug 4, 2020
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
A-SHIFT AB-SHIFT BMONTH-JAN
EMPLOYEE12345678DATES OF SHIFT A
EMP01AABAABBB
EMP02BBAABBBA
EMP03AAAABBBB
I Have this sample worksheet of attendance sheet. Can anybody help me to get the specific dates on which the employee was on shift A? Which formula or function is useful for this task?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Is this what you are looking for? If not, show us a mock up of what your result should look like.

Book21
AB
1EMPLOYEEDates.Attribute
2EMP011
3EMP012
4EMP014
5EMP015
6EMP023
7EMP024
8EMP028
9EMP031
10EMP032
11EMP033
12EMP034
Sheet2
 
Upvote 0
Is this what you are looking for? If not, show us a mock up of what your result should look like.

Book21
AB
1EMPLOYEEDates.Attribute
2EMP011
3EMP012
4EMP014
5EMP015
6EMP023
7EMP024
8EMP028
9EMP031
10EMP032
11EMP033
12EMP034
Sheet2
A-SHIFT AB-SHIFT BMONTH-JAN
EMPLOYEE12345678DATES OF SHIFT A
EMP01AABAABBB1,2,4
EMP02BBAABBBA
EMP03AAAABBBB
Result should look like this. In the last column all the dates should get for shift A.
In the 2nd row that numbers 1 2 3 4 upto 8 are dates.
 
Upvote 0
Try the function below (usage in column J), if you ever get Excel 2019 (or later) or Office 365 then you can use the formula in column K (please note if using Excel 2019 then you have to enter the formula with Ctrl + Shift + Enter and not just Enter).

VBA Code:
Function myTextJoin(Delimiter As String, myLetter As String, text_range As Range) As String

    Application.Volatile
    Dim myCell As Range, myCounter As Long
    myCounter = 0


    For Each myCell In text_range
        If myCell = myLetter Then
 
                If myCounter = 0 Then
                    myTextJoin = Cells(3, myCell.Column).Value ' change the 3 to your row number of "dates"
                Else
                    myTextJoin = myTextJoin & Delimiter & Cells(3, myCell.Column).Value ' change the 3 to your row number of "dates"
                End If
 
                myCounter = myCounter + 1
            End If

    Next

End Function

Book1
ABCDEFGHIJK
2A-SHIFT AB-SHIFT BMONTH-JANDATES OF SHIFT A 2019/Office365
3EMPLOYEE12345678
4EMP01AABAABBB1,2,4,51,2,4,5
5EMP02BBAABBBA3,4,83,4,8
6EMP03AAAABBBB1,2,3,41,2,3,4
Sheet1
Cell Formulas
RangeFormula
J4:J6J4=myTextJoin(",","A",$B4:$I4)
K4:K6K4=TEXTJOIN(",",TRUE,IF($B4:$I4="A",$B$3:$I$3,""))
 
Upvote 0
Try the function below (usage in column J), if you ever get Excel 2019 (or later) or Office 365 then you can use the formula in column K (please note if using Excel 2019 then you have to enter the formula with Ctrl + Shift + Enter and not just Enter).

VBA Code:
Function myTextJoin(Delimiter As String, myLetter As String, text_range As Range) As String

    Application.Volatile
    Dim myCell As Range, myCounter As Long
    myCounter = 0


    For Each myCell In text_range
        If myCell = myLetter Then

                If myCounter = 0 Then
                    myTextJoin = Cells(3, myCell.Column).Value ' change the 3 to your row number of "dates"
                Else
                    myTextJoin = myTextJoin & Delimiter & Cells(3, myCell.Column).Value ' change the 3 to your row number of "dates"
                End If

                myCounter = myCounter + 1
            End If

    Next

End Function

Book1
ABCDEFGHIJK
2A-SHIFT AB-SHIFT BMONTH-JANDATES OF SHIFT A 2019/Office365
3EMPLOYEE12345678
4EMP01AABAABBB1,2,4,51,2,4,5
5EMP02BBAABBBA3,4,83,4,8
6EMP03AAAABBBB1,2,3,41,2,3,4
Sheet1
Cell Formulas
RangeFormula
J4:J6J4=myTextJoin(",","A",$B4:$I4)
K4:K6K4=TEXTJOIN(",",TRUE,IF($B4:$I4="A",$B$3:$I$3,""))
Thank you very very much for this useful information. This is working for me. ?
 
Upvote 0
Happy it helped and welcome to the forum.

Btw, the answer to your question (sort of along the same lines) in the the other thread is you don't have the Morefunc addin.

I am unable to understand this formula on my excel sheet. Can you please help me out?
 
Upvote 0
FYI, After creating the list in post#2 by unpivoting the data in Power Query, I then put the data into Power Pivot and created the following Pivot Table. Just an alternative in case you are at all interested in other means.

Book22
ABCDE
1EMPLOYEEDates.Attribute
2EMP011EMPLOYEEAShift
3EMP012EMP011,2,4,5
4EMP014EMP024,3,8
5EMP015EMP031,2,4,3
6EMP023
7EMP024
8EMP028
9EMP031
10EMP032
11EMP033
12EMP034
13
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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