Autofilter to tak on an Inputted Value

G

Guest

I have a Macro that cleans down a report then moves on to filter out a list
of data for a date period using Autofiltering,

I have included the following to be prompted for the date to be filtered,
however it never filters on the date I input, I need to use an put method as
the report is required for different dates and then moves on to do other
things

Range("G1").Select

MyValue = Application.InputBox("Enter a Date")

Selection.AutoFilter Field:=7, Criteria1:=MyValue


Can anyone advise on how I can get the autofilter method to take on the
value from the input request

TIA
mmc308
 
B

Bryan Loeper

I have a Macro that cleans down a report then moves on to filter out a list
of data for a date period using Autofiltering,

I have included the following to be prompted for the date to be filtered,
however it never filters on the date I input, I need to use an put method as
the report is required for different dates and then moves on to do other
things

Range("G1").Select

MyValue = Application.InputBox("Enter a Date")

Selection.AutoFilter Field:=7, Criteria1:=MyValue

Can anyone advise on how I can get the autofilter method to take on the
value from the input request

TIA
mmc308

Maybe either "Criteria1:=CDate(MyValue)" or
"CDate(Applicaiton.InputBox("Enter a Date")"? For something more
sophisticated (and to prevent garbage input!) you could look at
http://www.fontstuff.com/vba/vbatut07.htm

-Bryan
 
G

Guest

Bryan

Thanks for your time sorted this by carrying out the following on the column

Range("G:G").Select
Selection.NumberFormat = "dd/mm/yyyy;@"

Many Thanks

mmc308
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top