ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print report based on criteria (https://www.excelbanter.com/excel-discussion-misc-queries/137468-print-report-based-criteria.html)

Rich Mogy

Print report based on criteria
 
Hi all,
I need to print a report on the work day (Monday through Friday) that is
closest to the 15th of the month. Which means that in April I would print
in on the 13th, May is Tuesday, 15th, June Friday 15, etc. The VBA program
that controls this report also controls others that are run everyday.

How can I code this, probably by setting a variable called PrintReport to
true on the right day.

Any thoughts would be appreciated.



JLatham

Print report based on criteria
 
Some logic such as shown in this Sub should do it for you.

Sub MidMonthCheck()
Dim MidMonthReportFlag As Boolean

MidMonthReportFlag = False
If Day(Now) = 15 And _
Weekday(Now) < vbSaturday And _
Weekday(Now) < vbSunday Then
'set flag TRUE
'it is 15th and it
'is a weekday
MidMonthReportFlag = True
ElseIf Day(Now) 12 And _
Day(Now) < 15 And Weekday(Now) = vbFriday Then
'set flag TRUE
'it is either 13th, or 14th
'and it's a Friday (with 15th on weekend)
MidMonthReportFlag = True
End If

End Sub


"Rich Mogy" wrote:

Hi all,
I need to print a report on the work day (Monday through Friday) that is
closest to the 15th of the month. Which means that in April I would print
in on the 13th, May is Tuesday, 15th, June Friday 15, etc. The VBA program
that controls this report also controls others that are run everyday.

How can I code this, probably by setting a variable called PrintReport to
true on the right day.

Any thoughts would be appreciated.




Rich Mogy

Print report based on criteria
 
That appears to be exactly what I need. I'll test and get back to you.
Thanks.
"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
Some logic such as shown in this Sub should do it for you.

Sub MidMonthCheck()
Dim MidMonthReportFlag As Boolean

MidMonthReportFlag = False
If Day(Now) = 15 And _
Weekday(Now) < vbSaturday And _
Weekday(Now) < vbSunday Then
'set flag TRUE
'it is 15th and it
'is a weekday
MidMonthReportFlag = True
ElseIf Day(Now) 12 And _
Day(Now) < 15 And Weekday(Now) = vbFriday Then
'set flag TRUE
'it is either 13th, or 14th
'and it's a Friday (with 15th on weekend)
MidMonthReportFlag = True
End If

End Sub


"Rich Mogy" wrote:

Hi all,
I need to print a report on the work day (Monday through Friday) that is
closest to the 15th of the month. Which means that in April I would
print
in on the 13th, May is Tuesday, 15th, June Friday 15, etc. The VBA
program
that controls this report also controls others that are run everyday.

How can I code this, probably by setting a variable called PrintReport to
true on the right day.

Any thoughts would be appreciated.







All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com