+ Reply to Thread
Results 1 to 6 of 6

non-working holidays

Hybrid View

  1. #1
    Registered User
    Join Date
    01-26-2007
    Posts
    21

    non-working holidays

    in Excel, I made ​​a table where the records of employees work.
    In column A2: A31 are the dates in January, etc.
    I wrote a function holidays and now
    in cell D2 I need a formula that will in cell A2 recognized holiday, and if
    the working day to enter No. 8
    For example: if the date in cell A2 1.1.2011. (Saturday) in cell D2 should be 0, and if the date 6.1.2011. (Thursday).
    should be No. 8.
    Holidays on Saturdays and Sundays should be excluded.
    Thank you for your help.
    Last edited by barkarlo; 05-23-2011 at 03:13 PM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: non-working holidays

    How about

    =(WORKDAY(A5-1,1,holidays)=A5)*8

    where holidays is the range of holiday dates

  3. #3
    Registered User
    Join Date
    01-26-2007
    Posts
    21

    Re: non-working holidays

    Quote Originally Posted by Bob Phillips View Post
    How about

    =(WORKDAY(A5-1,1,holidays)=A5)*8

    where holidays is the range of holiday dates
    I made a VBA code for dates of the holidays,.but how to apply the formula.
    Code looks like this:
    Public Function holiday(lngdate As Long) As Boolean
    Dim inputyear As Integer, es As Long, ok As Boolean
    
    If lngdate <= 0 Then lngdate = Date
    inputyear = Year(lngdate)
    es = eastersunday(inputyear)
    ok = True
    Select Case lngdate
    Case DateSerial(inputyear, 1, 1)
    Case DateSerial(inputyear, 1, 6)
    
    Case es
    Case es + 1
    Case DateSerial(inputyear, 5, 1)
    
    Case es + 60
    Case DateSerial(inputyear, 6, 22)
    Case DateSerial(inputyear, 6, 25)
    Case DateSerial(inputyear, 8, 5)
    Case DateSerial(inputyear, 8, 15)
    Case DateSerial(inputyear, 10, 8)
    Case DateSerial(inputyear, 11, 1)
    Case DateSerial(inputyear, 12, 25)
    Case DateSerial(inputyear, 12, 26)
    Case Else
    ok = False
    End Select
    holiday = ok
    End Function

  4. #4
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: non-working holidays

    It appears that you may be over complicating the situation slightly.
    Rather than a separate function for the holidays, there is a pre-existing function =Workday that functions similarly. This function uses an array for the holiday values.
    Rather than the imbedded dates within the VBA, I'd recommend setting those to another worksheet, and name the array of holidays (for however many years of data you have), as "Holidays"
    Then using Bob Phillip's equation, you can get what you're looking for within the employee data worksheet.

  5. #5
    Registered User
    Join Date
    01-26-2007
    Posts
    21

    Re: non-working holidays

    Quote Originally Posted by Miraun View Post
    It appears that you may be over complicating the situation slightly.
    Rather than a separate function for the holidays, there is a pre-existing function =Workday that functions similarly. This function uses an array for the holiday values.
    Rather than the imbedded dates within the VBA, I'd recommend setting those to another worksheet, and name the array of holidays (for however many years of data you have), as "Holidays"
    Then using Bob Phillip's equation, you can get what you're looking for within the employee data worksheet.
    OK, I'll make a separate table with a list of holidays, but would like to know how to implement a written VBA code in the formula.

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: non-working holidays

    Quote Originally Posted by barkarlo View Post
    OK, I'll make a separate table with a list of holidays, but would like to know how to implement a written VBA code in the formula.
    Why do you insist on that unnecessary step?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1