| |

VerySource

 Forgot password?
 Register
Search
View: 709|Reply: 1

Get all dates of the year and weekends

[Copy link]

4

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-20 14:30:01
| Show all posts |Read mode
I now know the year and month, such as 2016, May

What I want to do is fill the following into a line of EXCEL:

For all dates from May 2016 to the end of the year, if you encounter Saturday and Sunday, you must modify the corresponding CEll color
(The date of February is different in different years)
What should I do? Is there any useful method that I ca n’t get started, please help
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-6-28 09:00:01
| Show all posts
Private Sub Command1_Click()
    Dim dd As Date
    dd = CDate("2016-05-01")
    Do While (Year(dd) = "2016")
        If Weekday(dd, vbMonday) = 6 Or Weekday(dd, vbMonday) = 7 Then
            Debug.Print dd; "(weekend)"
        Else
            Debug.Print dd
        End If
        dd = DateAdd("d", 1, dd)
    Loop
End Sub
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list