Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Autofilter Delema

Thanks for the help. I'm also trying to loop this because this needs to
be done for several dates. I've tried using Do Until, Loop with the Do
Until in different spots (can you tell i'm a nubie?) hoping I would get
them in the right spot. But nothing seemed to work. Any direction on
using loops with input boxes?

wrote:
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 sheet. 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 worksheet, 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Autofilter Delema

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

Type:=2)
While myDate<FALSE do
Selection.AutoFilter Field:=2, Criteria1:=myDate
'etc
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _

Type:=2)
Loop

This will keep showing the input box until you click Cancel.
regards
Paul


Tsunami3169 wrote:

Thanks for the help. I'm also trying to loop this because this needs to
be done for several dates. I've tried using Do Until, Loop with the Do
Until in different spots (can you tell i'm a nubie?) hoping I would get
them in the right spot. But nothing seemed to work. Any direction on
using loops with input boxes?

wrote:
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 sheet. 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 worksheet, 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Autofilter Delema

Thanks again for this starting point. I tweeked it a little to end the
loop and an error message if the person entered an incorrect date.

Dim myDate As Variant
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _
Type:=2)
While myDate < False

Do 'Start Do..Loop

On Error GoTo InputError 'when error occurs
InputError: MsgBox ("Select a different date")

'Copy selection
Selection.AutoFilter Field:=2, Criteria1:=myDate
Application.Goto Reference:="Data_Select"
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _
Type:=2)

Exit Do

Loop

Wend

End Sub

wrote:
Hi
Dim myDate as Variant
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _

Type:=2)
While myDate<FALSE do
Selection.AutoFilter Field:=2, Criteria1:=myDate
'etc
myDate = Application.InputBox(prompt:="Please enter a date in the
format dd\mm\yyyy", _

Type:=2)
Loop

This will keep showing the input box until you click Cancel.
regards
Paul


Tsunami3169 wrote:

Thanks for the help. I'm also trying to loop this because this needs to
be done for several dates. I've tried using Do Until, Loop with the Do
Until in different spots (can you tell i'm a nubie?) hoping I would get
them in the right spot. But nothing seemed to work. Any direction on
using loops with input boxes?

wrote:
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 sheet. 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 worksheet, 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"