Dates of working days in a month

karthick.in

New Member
Joined
May 12, 2011
Messages
8
Is there anyway that I can populate the list of dates (only working days) in a month?

For example:
Cell A1 has the drop down list of all the months (Jan to Dec)
Cell A2 has the drop down of year (2011, 2012, 2013, ...)

If I select "Dec" in A1 and "2011" in A2, then column A3 should have the date of first working day in the month, B3 should have the date of next working day in the month, C3 should have the date next to it, etc...

In this case A3 = 01/12/2011; B3 = 02/12/2011; C3 = 05/12/2011 .... V3 = 30/12/2011

This should work for whatever month and year I select in A1 and A2.

The solution to do this would be much appreciated. Thanks!
 
Last edited:

trunten

Active Member
Joined
Jul 26, 2011
Messages
478
Assign this macro to a button and away you go :)
Code:
Sub a()
    sd = DateValue("01 " & [A1] & " " & [A2])
    cd = sd
    i = 1
    While Month(cd) = Month(sd)
        If Weekday(cd, vbMonday) < 6 Then
            Cells(3, i) = cd
            i = i + 1
        End If
        cd = cd + 1
    Wend
End Sub
 

GopherUK

Active Member
Joined
Jan 23, 2009
Messages
473
The formula is B2 is just to be dragged across columns (i.e. there are only teo unique formulas in the post - A2 and B2).
 

karthick.in

New Member
Joined
May 12, 2011
Messages
8
Assign this macro to a button and away you go :)
Code:
Sub a()
    sd = DateValue("01 " & [A1] & " " & [A2])
    cd = sd
    i = 1
    While Month(cd) = Month(sd)
        If Weekday(cd, vbMonday) < 6 Then
            Cells(3, i) = cd
            i = i + 1
        End If
        cd = cd + 1
    Wend
End Sub
Many Thanks!
 

Forum statistics

Threads
1,082,050
Messages
5,362,899
Members
400,696
Latest member
Kclynn

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top