-
Thanks very much Admin. I am running the code exactly as below with today's date in column 'T' but when filtered column 'T' is not shown :(
Code:
Sub todaysdels()
Dim rngFilter As Range
Dim dDate As Date
dDate = Date
Set rngFilter = Range("a2:z" & Range("a" & Rows.Count).End(xlUp).Row)
If Application.WorksheetFunction.CountIf(rngFilter.Columns(20), dDate) Then
rngFilter.AutoFilter field:=20, Criteria1:=dDate
Else
MsgBox "No delivery for today!", vbOKOnly
End If
End Sub
-
1 Attachment(s)
Hi
Here is screenshot of what I got.
Attachment 407
-
1 Attachment(s)
Try this one attached. Code below....
I have changed the formula used in Column T. This is working at my side....
Code:
Option Explicit
Sub FilterToday()
FilterForDate Date
End Sub
Sub FilterTomorrow()
FilterForDate CDate(Date + 1)
End Sub
Sub FilterForDate(dDate As Date)
With Worksheets("test")
.Range("A2").AutoFilter field:=20, Criteria1:=dDate
If .Range("T3:T1000").Find(dDate, , xlValues) Is Nothing Then
MsgBox "No delivery for today!", vbOKOnly
End If
End With
End Sub
-
Thanks Both for your help. The strangest thing, I pasted the code into the version I use at work and the sheet works fine. Only problem is I have 4 sheets for 4 different customers. Much the same but some solumn info different. I tried to use the same code to filter todays deliveries on another sheet and it doesnt work. The delivery date it in column 16 this time so I changed the code but nothing shows once filtered. Any ideas where I am going wrong?
Code:
Sub todaysdels()
Set rngFilter = Range("a2:P400" & Range("a" & Rows.Count).End(xlUp).Row)
dDate = Date
If Application.WorksheetFunction.CountIf(rngFilter.Columns(16), dDate) Then
rngFilter.AutoFilter field:=16, Criteria1:=dDate
Else
MsgBox "There are no delivery for today!", vbOKOnly
End If
End Sub
-
Thanks All. Now works brilliant! The code was perfect it was the cell formate giving me trouble :) Cheers