Print sequential dates skipping certain days

pete2583

New Member
Joined
Jul 10, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have created a production spreadsheet for work and and have set it to automatically print everyday of the month. The below is the macro that I used for this (stolen from Google)


VBA Code:
Sub meddaydate()
Dim d1 As Date
    Dim d As Date
    Application.ScreenUpdating = False
    d1 = Range("E3").Value
    For d = DateSerial(Year(d1), Month(d1), 1) To DateSerial(Year(d1), Month(d1) + 1, 0)
        Range("E3").Value = d
        ActiveSheet.PrintOut
    Next d
    Application.ScreenUpdating = True
End Sub

However, I need to create another sheet for a different department who only work Mon-Thur So only need to print out paperwork for every Mon-Thur. Is there a way to adapt the above macro to skip the 3 days I don't require?

Thanks, in advance for any help that you can give.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the forum. :)

You can test the weekday of each date - e.g.

VBA Code:
Sub meddaydate()
Dim d1 As Date
Dim d As Date
Application.ScreenUpdating = False
d1 = Range("E3").Value
For d = DateSerial(Year(d1), Month(d1), 1) To DateSerial(Year(d1), Month(d1) + 1, 0)
select case weekday(d, vbmonday)
case 1 to 4
Range("E3").Value = d
ActiveSheet.PrintOut
end select
 Next d
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Wow. Thank you so much. I'm really new to Macro/VBA and it's quite a steep learning curve. This is great though.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top