Results 1 to 5 of 5

Generating List of Week Working days and Identifying Holidays

Threaded View

  1. #1
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Generating List of Week Working days and Identifying Holidays

    From another thread I got this formula placed on B5:
    =NETWORKDAYS(EOMONTH(B4,-1)+1,EOMONTH(B4,0),Holidays)

    his generates the number of working days for that month (regardless of the date on B4) that exclude Holidays listed under the range "Holidays".

    I also got this code (Credits to XXXX)

    Private Sub Worksheet_Change(ByVal Target As Range)
     
    Dim rng As Range
    Dim d As Long
        If Target.Column = 3 Then
            Application.EnableEvents = False
            With Sheets("TIMES")
                .Range("B4").Value = Date
                Set rng = .Range("B7")
                For d = DateSerial(Year(Date), Month(Date), 1) To DateSerial(Year(Date), Month(Date) + 1, 0)
                    Select Case Weekday(d)
                        Case 1, 7
                            ' do nothing because it's not a weekday
                        Case Else
                            rng.Value = d
                            rng.NumberFormat = "dddd dd"
                            Set rng = rng.Offset(1)
                    End Select
                Next d
            End With
        End If
        Application.EnableEvents = True
     
    End Sub
    That will generate the number of week days. However, this is my issue, and those that understand the code will notice, that regardless of the date I input on B4, say May 5, 2009, but as I enter something on column C, it will change my B4 date to Oct 28 and give me all week days for October only. I will then change B4 to say June 5, 2009, and delete the dates generated by the code and input something on Column c again, and again, it will change B4 to Oct 28,2009.

    Any ideas on how tell the code not to change my date, and generate the week days for the month of the date on B4 instead. And then naturally, if there is a holiday in that range generated, it will list the day as well (i.e. it will not be excluded). This is fine, however, can anybody help me to put beside the holiday date (listed under range Holiday) on the range generated by code the word "Holiday", and beside all others "Working Day"?

    Thank you.

    Ron
    Excel2003

    EDIT

    I have deleted this line:
    .Range("B4").Value = Date

    Now it doesn't change the date on B4, but the list of week days generated is still for October!! :-(
    Last edited by ron2k_1; 10-29-2009 at 02:25 PM. Reason: Solved: Thank you, thank you DonkeyOte

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