Creating a Leave Tracker/Attendance Tracker

cloud2828

New Member
Joined
Jul 16, 2019
Messages
43
I'm extremely new to excel, initially I created this program in VBA but after running it, it would take over five minutes to process so I had to start over using Excel formulas. I am familiar with coding that's why I decided to do it VBA but the logic is Excel formulas are so complex to me I can't figure out what I would need to do. I already have a calendar that goes horizontally across my worksheet for a year period. What I would like to do is have employee names next to the calendar and highlight the days they are here and not through a table on another worksheet where you would type in the information (e.g. Person's name, type of leave, date they're leaving and date they're coming back). The issue I'm having is within this table, there will be duplicate names that must be accounted for and when I try to use Match Index functions, it only matches the first duplicate it sees. Doing some research I found a formula to find duplicate names which worked find, I altered it to my use but the problem with it is that it only accounts for one duplicate name and I can ONLY get back duplicate names and not the rest of names.

Let me explain more what this formula is supposed to do, it is supposed to match a name from one worksheet to the next worksheet with the calendar. The worksheet without the calendar has a table where the name and date range and type of leave etc is inputted. Once this is inputted, the date range should be highlighted and state the type of leave on the calculator under their name.

=IF(AND(E$8 >= INDEX(Table1;MATCH($AJ29;Table1[Column1];0);2); E$8<=INDEX(Table1;MATCH($AJ29;Table1[Column1];0);3));"Z";"W")

The code above is not able to account for duplicates but it works as intended

=IF(ROWS(AR$30:AR30)<=COUNTIF($AO$11:AO16;AJ$29);INDEX(AP$11:AP$16;SMALL(IF(AO$11:AO$16=AJ$29;ROW(AO$11:AO$16)-10);ROWS(AR$30:AR30)));INDEX(AO$11:AQ16;MATCH($AO11;AO$11:AO16;0);2))

This one accounts for the column where you put in the starting date in the table but can only account for ONE duplicate name at a time.

I've been trying for quite some time to implement both of these. My logic is that it should be a nested if statement where it will account for all the duplicates then afterwards account for the remaining names in the table. I know there must be an easier way to do this but I can't think of any other way.

All I basically want, is to find a way for match index to account for duplicate names, I feel like there should be a very simple method to do this and that my formula is extremely excessive.
 
Sure, you can just post this on a different sheet and point the reference to this sheet i have posted the output on the new sheet3 and it is referring to sheet2:

ABCDEFG
1NamesRows
2Name101512
3Name1467

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet3

Worksheet Formulas
CellFormula
B2=IFERROR(AGGREGATE(15,6,(ROW(Sheet2!$A$2:$A$13)-ROW(Sheet2!$A$2)+1)/($A2=Sheet2!$A$2:$A$13),COLUMNS(B2:$B2)),"")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Thank you again, there's a lot of work I need to do before I get this to work, will let you know if I get through with it!
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Glad could help & sure, let us know if you face any issues.
 
Upvote 0
Glad could help & sure, let us know if you face any issues.

I'm already facing an issue, basically I would like to refer the rows back to the rows in the table I have, is that possible? For help in understanding, currently in sheet 1 the table's rows are at cells AJ20 to AJ25 but as you know I currently have the row numbers in sheet 2 at E2:I2 and downwards. So is it possible I can translate the row numbers to the table that I have in sheet 1? I still feel like I'm over-complicating this but if I can figure this out I will be done with this. Would also like to know how I can add an OR statement to this formula:

=IF(AND(E$8 >= INDEX(Table1;MATCH($AJ29;Table1[Column1];0);2); E$8<=INDEX(Table1;MATCH($AJ29;Table1[Column1];0);3));"Z";"W")

Currently "MATCH($AJ29;Table1[Column1];0);2)" is giving the row of the table for the index but in order to have multiple date ranges for one person, I'd need an OR statement by that part of the index formula where you enter the row to account for the other rows if there are duplicate names.
 
Upvote 0
Can you upload a sample dummy file to dropbox.com or google drive and can share the link. Please do fill in the expected result. will check it out.
 
Upvote 0
Can you upload a sample dummy file to dropbox.com or google drive and can share the link. Please do fill in the expected result. will check it out.

https://drive.google.com/file/d/1NxcwnW7Txp0lRyKqLgyrOEzVmrPkWwpT/view?usp=sharing

This is the link to my excel file, i highlighted a border so everything beyond that is just me testing stuff and is not important to you, currently I have the calendar set from January 1st to 31st 2019. It matches the names in the two tables and gives the row of the table which has the dates, the index function is used with match to get the row and the column is set to 2/3 depending on if it is start date or end date. I created an AND statement with an IF statement that basically compares the start date and end date such that if the value falls between the range, return "Z" and if it doesn't return "W". The problem I am currently getting is that match cannot deal with duplicates so it will never see the duplicated name thus not being able to obtain the row in which it is resulting in not getting the start and end date to be compared. I think you will understand what I'm trying to do once you look at the excel file.
 
Upvote 0
Hi, I copied your data on an excel and just worked on the double part, Think below should work for you:


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1NamesTue 01Wed 02Thu 03Fri 04Sat 05Sun 06Mon 07Tue 08Wed 09Thu 10Fri 11Sat 12Sun 13Mon 14Tue 15Wed 16Thu 17Fri 18Sat 19Sun 20Mon 21Tue 22Wed 23Thu 24Fri 25Sat 26Sun 27Mon 28Tue 29Wed 30Thu 31
2Name1ZZZZWWZZZZWWWWWWWWWWWWWWWWWWWWW
3Name2ZZZZZZZZZZZZZZZZWWWWWWWWWWWWWWW
4Name3ZZZZZZWWWWWWWWWWWWWWWWWWWWWWWWW
5Name4ZZZZZZZZZZZZZZZZWWWWWWWWWWWWWWW
6Name5ZZZZZZZZZZZZZZZZWWZZZZZWWWWWWWW
7Name6WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
8
9
10
11
12
13Column1Column2Column3Desc
14Name11/1/20191/4/2019A
15Name21/1/20191/16/2019B
16Name31/1/20191/6/2019C
17Name41/1/20191/16/2019A
18Name51/1/20191/16/2019B
19Name51/19/20191/23/2019E
20Name11/7/20191/10/2019A
Sheet1
Cell Formulas
RangeFormula
B2=IF(AGGREGATE(14,6,($A$14:$A$20=$A2)*($B$14:$B$20<=B$1)*($C$14:$C$20>=B$1),1),"Z","W")


Copy the formula from on B2:AF7
 
Upvote 0
Hi, I copied your data on an excel and just worked on the double part, Think below should work for you:

ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1NamesTue 01Wed 02Thu 03Fri 04Sat 05Sun 06Mon 07Tue 08Wed 09Thu 10Fri 11Sat 12Sun 13Mon 14Tue 15Wed 16Thu 17Fri 18Sat 19Sun 20Mon 21Tue 22Wed 23Thu 24Fri 25Sat 26Sun 27Mon 28Tue 29Wed 30Thu 31
2Name1ZZZZWWZZZZWWWWWWWWWWWWWWWWWWWWW
3Name2ZZZZZZZZZZZZZZZZWWWWWWWWWWWWWWW
4Name3ZZZZZZWWWWWWWWWWWWWWWWWWWWWWWWW
5Name4ZZZZZZZZZZZZZZZZWWWWWWWWWWWWWWW
6Name5ZZZZZZZZZZZZZZZZWWZZZZZWWWWWWWW
7Name6WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
8
9
10
11
12
13Column1Column2Column3Desc
14Name11/1/20191/4/2019A
15Name21/1/20191/16/2019B
16Name31/1/20191/6/2019C
17Name41/1/20191/16/2019A
18Name51/1/20191/16/2019B
19Name51/19/20191/23/2019E
20Name11/7/20191/10/2019A

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=IF(AGGREGATE(14,6,($A$14:$A$20=$A2)*($B$14:$B$20<=B$1)*($C$14:$C$20>=B$1),1),"Z","W")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Copy the formula from on B2:AF7

Thank you so much... I'm actually mind blown that you made this work with such simple code, I will have to do some research on AGGREGATE because I was trying to create a VBA module to add functions to existing formula but this is SO much simpler. I am still blown away by this, the only problem now is that the list with the reoccurring names and dates will keep expanding so that table will continuously be getting larger, is there a way to alter the formula such that when the table size increases, so does the ratio in the formula?
 
Upvote 0
Also, instead of "Z" I need it write the value in the "Desc" column when true e.g, A, B, C, etc.

This might make things a lot more complicated maybe, because Name1 can have different descriptions for different days and same for the other Names.
 
Upvote 0
Yeah, below formula will have to be used for getting description:


Book1
B
2ABC
Sheet1
Cell Formulas
RangeFormula
B2{=IFERROR(INDEX($D$14:$D$20,SMALL(IF(($A$14:$A$20=$A2)*($B$14:$B$20<=B$1)*($C$14:$C$20>=B$1),ROW($D$14:$D$20)-ROW($D$14)+1),1)),"W")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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