PC Review


Reply
Thread Tools Rate Thread

Autofilter Delema

 
 
Tsunami3169
Guest
Posts: n/a
 
      14th Nov 2006
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.

 
Reply With Quote
 
 
 
 
Tsunami3169
Guest
Posts: n/a
 
      14th Nov 2006

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 With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      14th Nov 2006
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 With Quote
 
Tsunami3169
Guest
Posts: n/a
 
      16th Nov 2006
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?

(E-Mail Removed) 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 With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      16th Nov 2006
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?
>
> (E-Mail Removed) 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 With Quote
 
Tsunami3169
Guest
Posts: n/a
 
      21st Nov 2006
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

(E-Mail Removed) 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?
> >
> > (E-Mail Removed) 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Here's my delema Amy E. Baggott Microsoft Access Reports 0 5th May 2009 08:11 PM
File Transfer delema =?Utf-8?B?T2xkc3BpY2U=?= Windows Vista General Discussion 3 12th Jun 2007 01:49 AM
XP Pro Licence Delema Gordon Microsoft Outlook 2 26th Jun 2005 01:18 AM
XP Pro Licence Delema Gordon Windows XP Security 4 25th Jun 2005 01:17 AM
SATA drive delema =?Utf-8?B?THRGYXNz?= Windows XP General 5 11th Jan 2005 06:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:17 AM.