Adding new date column but excluding weekends

chris54

New Member
Joined
Aug 23, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I've been using the code stated below for some time to create a new column for a "due date" which would be 30 days from the chosen input. The problem is that within those 30 days weekends are not being excluded meaning many of the dates are incorrect. Is there a way to integrate weekday or perhaps another function within my code so the "due date" calculated automatically excludes weekends?

Billdate = Application.InputBox("Enter 1st day of Current Month Billing eg 01-Jan-2015")
StartTRX = "<" & Billdate ' 01/10/15
EndTRX = Application.EoMonth(Billdate, 0) '31/10/15
EndTRX = ">" & EndTRX

StartDue = Application.EoMonth(Billdate, 0) ' 30/11/15

EndDue = Application.EoMonth(Billdate, 1) ' 31/10/15
StartDue = "<=" & StartDue ' due date
EndDue = ">" & EndDue ' due date =

Range("AZ3").Select
Selection.AutoFilter
Range("BC1").Select
ActiveSheet.Range("$A$3:$BA$70000").AutoFilter Field:=52, Criteria1:= _
StartTRX, Operator:=xlOr, Criteria2:=EndTRX
Range("AZ4").Select
Range(Selection, Selection.End(xlDown)).Select
'Range("AZ122").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
ActiveSheet.Range("$A$3:$BA$70000").AutoFilter Field:=52
ActiveSheet.Range("$A$3:$BA$70000").AutoFilter Field:=53, Criteria1:= _
StartDue, Operator:=xlOr, Criteria2:=EndDue
Range("BA4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
ActiveSheet.Range("$A$3:$BA$70000").AutoFilter Field:=53
Range("AZ4").Select
pivots
 

Attachments

  • Capture.JPG
    Capture.JPG
    106.8 KB · Views: 7

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You can use the WORKDAY and NETWORKDAYS function in VBA like this:
Application.WorksheetFunction.Workday...
Application.WorksheetFunction.NetWorkdays...


I think you should be able to use those to do what you want.
Check out Microsoft's on-line help on those two functions if you are not familiar with them.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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