Re: Autofilter Delema

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi
You will need something like;
Dim myDate as Variant
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _

Type:=2)
If myDate = False then
Exit sub 'cancel clicked
else
Selection.AutoFilter Field:=2, Criteria1:=myDate
'etc
end if

The myDate variable is expecting a string (type 2).
This is a beginning. The Autofilter searches on a STRING, so the input
date format must be the same as is on the ***. you must also error
check the inputbox value to check it is the correct format.

regards
Paul

Tsunami3169 wrote:

Tsunami3169 wrote:
My problem is I have a workbook that auto imports a text doc. I then
run a macro to format the work***, data and set an auto filter. I
filter column B to select the correct date which to copy the data
needed. Is there a macro I can use to automate the auto filter using a
pop up input box? So when a user inputs a date the data will be
filtered by that date. I'm some what new to macros and have searched
many web pages looking for an answer. Any help would be greatly
appreciated.

Oops I forgot to add the macro I currently use. This is what I
currently use but it will only filter on yesterdays date.

Selection.AutoFilter Field:=2, Criteria1:=Date - 1
Application.Goto Reference:="Data_Select"
Selection.Copy

.


Quantcast