ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofilter to tak on an Inputted Value (https://www.excelbanter.com/excel-programming/389691-autofilter-tak-inputted-value.html)

mmc308

Autofilter to tak on an Inputted Value
 
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


Bryan Loeper

Autofilter to tak on an Inputted Value
 
On May 19, 9:22 am, mmc308 wrote:
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


mmc308

Autofilter to tak on an Inputted Value
 
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

"Bryan Loeper" wrote:

On May 19, 9:22 am, mmc308 wrote:
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




All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com