Weekday Filter help required

colbecd

New Member
Joined
Apr 30, 2009
Messages
25
Hi

Hoping someone will be able to help, I have the below VBA code to filter by date + 2 however on a "Friday" I want this to search for "Tuesday" is there a way that i can code the below to searh for only working days ie Monday to Friday and skip weekends?

Sub Filterbydate()
Sheets("Report").Select
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$I$1775").AutoFilter Field:=6, Operator:= _
xlFilterValues, Criteria2:=Array(2, Date + 2)
Rows("2:10000").Select
Selection.Delete Shift:=xlUp
ActiveSheet.ShowAllData
Range("A1").Select
End Sub


Many thanks in advance!!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
maybe like this?

Code:
Sub Filterbydate()
If Weekday(Date + 1, vbUseSystemDayOfWeek) = 6 Or Weekday(Date + 2, vbUseSystemDayOfWeek) = 7 Then
Date1 = Date + 4
Else
Date1 = Date + 2
End If
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$I$1775").AutoFilter Field:=6, Operator:= _
xlFilterValues, Criteria2:=Array(2, Date1)
Rows("2:10000").Select
Selection.Delete Shift:=xlUp
ActiveSheet.ShowAllData
Range("A1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,822
Messages
6,132,915
Members
449,768
Latest member
LouBa

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