COMPLEX FORMULA NEED

AABID QURESHI

New Member
Joined
Dec 6, 2020
Messages
20
Office Version
  1. 2010
Platform
  1. Windows
Hi this is Aabid here.
I need a formula which returns me start and end date of Leave, Absent and likely to be given values.

Suppose an employee is on leave from 08 to 17, it is marked in sheet, then it should return first start date and end date.
Please help about it.



S. No.Employee CPeEmployee NameDesignationDepartmentDate Joined01-12-202002-12-202003-12-202004-12-202005-12-202006-12-202007-12-202008-12-202009-12-202010-12-202011-12-202012-12-202013-12-202014-12-202015-12-202016-12-202017-12-202018-12-202019-12-202020-12-202021-12-202022-12-202023-12-202024-12-202025-12-202026-12-202027-12-202028-12-202029-12-202030-12-2020FROMTO
1242MAHAVEER SINGH NATHWATSR. FOREMANPLANT & EQUIPMENTS19-03-2006WPPPPODODODODODODPPHHAAPPPPWPPPPPPPP
2448ARVIND KUMARCONSTRUCATION MANAGERHIGHWAY01-08-2007WPPPPPPWPPPPELHHPPPPPPWPPPPPPPP
3787RAJESH SINGALPROJECT COORDINATOROPERATION25-04-2008WPPPPPPELELELELELELHHELELPPPPWPPPPPPPP
41489ASHOK PRASAD SINGHFOREMANHIGHWAY15-02-2010WPPPPPPWPPPPPHHPPPPPPWPPPPPPPP
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I told you, In this situation, it is better to count Leaves. This is formula:
Excel Formula:
=COUNTIF($G3:$AJ3,"EL")
 
Upvote 0
What about in this condition sir, if leaves are marked in different cells also.
This will be great help from your side.


ATTENDANCE AUTHENTIC SHEET NOV 20.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMAN
2S. No.Employee CODEEmployee NameDesignationDepartmentDate Joined01-12-202002-12-202003-12-202004-12-202005-12-202006-12-202007-12-202008-12-202009-12-202010-12-202011-12-202012-12-202013-12-202014-12-202015-12-202016-12-202017-12-202018-12-202019-12-202020-12-202021-12-202022-12-202023-12-202024-12-202025-12-202026-12-202027-12-202028-12-202029-12-202030-12-2020LEAVE FROMTOABSENT FROMTO
31242MAHAVEER SINGH NATHWATSR. FOREMANPLANT & EQUIPMENTS19-03-2006WPPPPELELELELELELPPHHAAPPPPWPPPELELPELP06-12-202029-12-2020
42448ARVIND KUMARCONSTRUCATION MANAGERHIGHWAY01-08-2007WPPPPPPWPPPPELHHPPPAPPWPPPPPPPP
53787RAJESH SINGALPROJECT COORDINATOROPERATION25-04-2008WPPPPPPELELELELELELHHELELPPPPWPPPPPPPP
641489ASHOK PRASAD SINGHFOREMANHIGHWAY15-02-2010WPPPPPPWPPPPPHHPPPPPPWPPPPPPPP
Sheet1
 
Upvote 0
Then Which one you wants to Return Address.
 
Upvote 0
Then Which one you wants to Return Address
Every start and leave dates.
like if first leave is from 01 to 03 then its start and end date.
After its starting from 7 to 10 then it should be return from 07 to 10.
and likely to be this
 
Upvote 0
I write this function (UDF).
Press ALT+F11 to go VBA window. then GO Insert , Procedure,
then use this name for function FindELDates
Select Function on Type Section and Press OK
Delete all code at code window and then Paste this code:
VBA Code:
Option Explicit
Public Function FindELDates(InputData As Range, Criteria As Range) As String
Dim x As Long
Dim y As String
Dim cell As Range

 y = ""
 For Each cell In InputData
  If cell.Value = Criteria Then
   x = Day(Cells(1, cell.Column))
      If y <> "" Then
        y = y & ", " & x
       Else
        y = x
      End If
  End If
Next cell
FindELDates = y
End Function
Save your file as Macro-Enabled Workbook (.xlsm)

Then in Excel window in One Cell write:
=FindELDates
Select function from list and first input your range then comma and then your criteria (also you can select both)
 
Upvote 0
One thing I forgot for Previous Post.
Before go Insert Procedure
You should Insert Module
And this is second version of Formula. Also test this.
VBA Code:
Public Function FindELDates(InputData As Range, Criteria As Range) As String
Dim x As Long
Dim y As String
Dim cell As Range

 y = ""
 For Each cell In InputData
  If cell.Value = Criteria Then
   x = Day(Cells(1, cell.Column))
      If y <> "" Then
       If cell.Value = cell.Offset(0, -1).Value Then
          If cell.Value = cell.Offset(0, 1).Value Then
              y = y
           Else
            y = y & " to " & x
          End If
        Else
            y = y & ", " & x
        End If
       Else
        y = x
      End If
  End If
  Debug.Print y
Next cell
FindELDates = y
End Function
 
Upvote 0
One thing I forgot for Previous Post.
Before go Insert Procedure
You should Insert Module
And this is second version of Formula. Also test this.
VBA Code:
Public Function FindELDates(InputData As Range, Criteria As Range) As String
Dim x As Long
Dim y As String
Dim cell As Range

y = ""
For Each cell In InputData
  If cell.Value = Criteria Then
   x = Day(Cells(1, cell.Column))
      If y <> "" Then
       If cell.Value = cell.Offset(0, -1).Value Then
          If cell.Value = cell.Offset(0, 1).Value Then
              y = y
           Else
            y = y & " to " & x
          End If
        Else
            y = y & ", " & x
        End If
       Else
        y = x
      End If
  End If
  Debug.Print y
Next cell
FindELDates = y
End Function
Sir,
Please check it, not working from my end, may be i am doing wrong.

FindELDates.xlsm
C
8#NAME?
Sheet1
Cell Formulas
RangeFormula
C8C8=FindELDates(A3:AD3,"el")
 
Upvote 0

Forum statistics

Threads
1,215,559
Messages
6,125,517
Members
449,236
Latest member
Afua

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