monkeyharris
Active Member
- Joined
- Jan 20, 2008
- Messages
- 370
- Office Version
- 365
- Platform
- Windows
Hi all,
I recorded a Macro to make the same task easier. problem is, there's a section to automatically filter then select a date. Obviously the macro will then always filter by the date i selected. Is there a way to make this always filter by the next day. IE, if today is 17/10/23, can the code automatically look for 18/10/23?
Thinking ahead for my next problem which will be on a Friday, it would need to look up the Monday as we don't work weekends. If that's too much to ask and someone can help with the first problem, that's great. Code below:
I recorded a Macro to make the same task easier. problem is, there's a section to automatically filter then select a date. Obviously the macro will then always filter by the date i selected. Is there a way to make this always filter by the next day. IE, if today is 17/10/23, can the code automatically look for 18/10/23?
Thinking ahead for my next problem which will be on a Friday, it would need to look up the Monday as we don't work weekends. If that's too much to ask and someone can help with the first problem, that's great. Code below:
VBA Code:
Sub OpenSalesOrders()
'
' OpenSalesOrders Macro
'
'
Columns("J:L").Select
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$335").AutoFilter Field:=13, Criteria1:= _
"Delivery"
Columns("A:B").Select
Range("B1").Activate
Selection.Delete Shift:=xlToLeft
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("B1:B335"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("B1:B335"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$S$335").AutoFilter Field:=2, Criteria1:= _
"18/10/2023"
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("M1:M335"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B4").Select
End Sub
Last edited by a moderator: