Found Dates between Gaps

vishal0589

Board Regular
Joined
May 13, 2014
Messages
63
Hi Friends,
I am working with a attendance register where I have to check gap between two subsequent Weekly Offs (W/O) with following conditions.
-> There must be 4 Present (P) between two Weekly Offs (W/O).
-> If Minimum 4 present (P) is not available between two Weekly Offs (W/O), dates of W/O will be resulted in columns

for example.

S. No.Emp. No.12345678910111213Output
1143PPPPW/OPPW/OPPPPW/O58
2499PW/OPPPPW/OPPPELELW/O713
3501PPPPCLPPPPW/OPPP
4505PW/OPPPPW/OCLPPPW/OP712
5
506PPCLPPW/OPELPPW/OPP611
6
509PW/OP
PPPW/OPPPPCLP
7758
PW/OPCLCLPW/OPPCLPW/OP2712

<colgroup><col span="2"><col><col span="17"></colgroup><tbody>
</tbody>

<colgroup><col span="2"><col><col><col span="18"></colgroup><tbody>
</tbody>



Please help me out.

Thanks in Advance.

CMA Vishal Srivastava
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
employee 143 has week 5 off, if he had only worked one week and asked for another week off this would have been refused presumably, so you just want week numbers where employee took the week off ?
 
Upvote 0
This is what we are looking for. We have to check whether employee have completed atleast 4 Present (P) between two Weekly OFFs.

If 4 P not available then Weekly off dates should be resulted.
 
Upvote 0
S. No.Emp. No.W1W2W3W4W5W6W7W8W9W10W11W12W13Output13WEEK PERIOD
1143PPPPW/OPPW/OPPPPW/OW5W8W13
2499PW/OPPPPW/OPPPELELW/OW2W7W13
3501PPPPCLPPPPW/OPPPW10
4505PW/OPPPPW/OCLPPPW/OPW2W7W12
5506PPCLPPW/OPELPPW/OPPW6W11
6509PW/OPPPPW/OPPPPCLPW2W7
7758PW/OPCLCLPW/OPPCLPW/OPW2W7W12
this macro runs through the data and produces the output table
Dim aa(25)
For k = 2 To 8
For j = 3 To 3 + Cells(1, 21) - 1
If Cells(k, j) = "W/O" Then Sum = Sum + 1: aa(Sum) = Cells(1, j)
Next j
If Sum = 0 Then GoTo 50
For b = 17 To 17 + Sum
tot = tot + 1
Cells(k, b) = aa(tot)
Next b
For c = 1 To 25
aa(c) = ""
Next c
tot = 0
Sum = 0
50 Next k
End Sub

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col span="10"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi,
I think there is problem in implementing your macro. As I am not able to use it. If any thing i m missing pls expain..
 
Last edited:
Upvote 0
i wrote it and tested it - it produces the output shown in my post - if you PM me with your Email I am happy to send the spreadsheet across. This action does not breach forum guidelines as a solution is already posted.
 
Upvote 0
Also it seems there is an error in your solution.

I just want to know those Weekno where 4 Presents where not available between two subsequent Weekly offs (W/O).

Your macro gives all Weeknos.
 
Upvote 0
I have sent the email and it did not bounce..........

but it is true I misread the question - you want to know if there are 3 or less P's between a pair of W/O 's
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

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