Results 1 to 11 of 11

Holiday Function - Show/Hide 1st of May.

Threaded View

  1. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: Holiday Function - Show/Hide 1st of May.

    Hi there,

    Many thanks for that very clear description of your requirements.

    Take a look at the attached workbook and see if it does what you need. I have rewritten your "HelligdagsNavn" routine as follows:

    
    
    Function HelligdagsNavn(lngdate As Long, InclSaturdays As Boolean, _
                            InclSundays As Boolean, Optional sYesNo As String) As String
    
    '   Returnerer Sand hvis lngDate er en Dansk HelligdagsNavn/nationaldag
    '   (valgfri inkludering af lordag/sondag)
    '   bruger funktionen Paskedag
    
        Dim InputYear As Integer, PD As Long    '    <<<  The "OK" variable is not used
    
        If lngdate <= 0 Then
            lngdate = Date
        End If
    
        InputYear = Year(lngdate)
        PD = Paskedag(InputYear)
    
        Select Case lngdate ' Tester nedenstaende pastande mod datoen
    
            Case DateSerial(InputYear, 1, 1): HelligdagsNavn = "Nytarsdag"
            Case PD - 3: HelligdagsNavn = "Skaertorsdag"
            Case PD - 2: HelligdagsNavn = "Langfredag"
            Case PD: HelligdagsNavn = "Paskedag"
            Case PD + 1: HelligdagsNavn = "2. Paskedag"
            Case PD + 26: HelligdagsNavn = "Store Bededag"
            Case PD + 39: HelligdagsNavn = "Kr. Himmelfartsdag"
            Case PD + 49: HelligdagsNavn = "Pinsedag"
            Case PD + 50: HelligdagsNavn = "2. Pinsedag"
            Case DateSerial(InputYear, 12, 24): HelligdagsNavn = "Julaftensdag"
            Case DateSerial(InputYear, 12, 25): HelligdagsNavn = "1. Juledag"
            Case DateSerial(InputYear, 12, 26): HelligdagsNavn = "2. Juledag"
            Case DateSerial(InputYear, 12, 31): HelligdagsNavn = "Nytarsaftensdag"
            Case DateSerial(InputYear, 6, 5): HelligdagsNavn = "Grundlovsdag"
    
            Case DateSerial(InputYear, 5, 1): HelligdagsNavn = "1. Maj"
    
                If UCase(sYesNo) = "YES" Then
                      HelligdagsNavn = "1. Maj"
                Else: HelligdagsNavn = ""
                End If
    
            Case Else
    
        End Select
    
        If InclSaturdays Then       '   Tester lordage, hvis de skal medtages
    
            If Weekday(lngdate, vbMonday) = 6 Then
                HelligdagsNavn = HelligdagsNavn & " Lordag"
            End If
    
        End If
    
        If InclSundays Then         '   Tester sondage, hvis de skal medtages
    
            If Weekday(lngdate, vbMonday) = 7 Then
                HelligdagsNavn = HelligdagsNavn & " Sondag"
            End If
    
        End If
    
    End Function

    The optional argument "sYesNo" is used only in Cell B4 (for the date of 1 May yyyy) as follows:

    
    =HelligdagsNavn(A4,  0,  0,  D10)
    where D10 is the cell which contains the Yes / No value


    For all other cells the function is entered without the optional argument, e.g.

    
    =HelligdagsNavn(A5,  0,  0)

    As far as I can tell, it's not really necessary to include your error handling when the function is used, i.e.

    
    =IFERROR(IF(A5="","",HelligdagsNavn(A5,0,0)),"")

    Please note that in order to get the site to accept this post I have had to use the highlighted "English" letters as replacements for the original Danish ones - the attached workbook contains the Danish characters copied from your workbook.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 03-09-2015, 11:42 PM
  2. [SOLVED] IF function using WORKDAYS and a Bank Holiday list - trying to add new holiday dates
    By jowarks in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-05-2013, 05:42 AM
  3. Function/VBA or something to show hide signature(image) using a pin number.
    By smarcins in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2012, 05:39 AM
  4. Show how many days holiday
    By Newtransistorhero in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 11-23-2009, 12:05 PM
  5. show holiday
    By pichai in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2008, 09:31 AM
  6. [SOLVED] Holiday Planner show holiday taken?
    By Mac5 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-23-2006, 01:23 PM
  7. show value but hide function
    By idanovich@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2006, 03:05 PM

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