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


Hello,

Could someone please take a look at my VBA code and advise how to mak
it work correctly:

Sub PrintOutByMonth()
'
'PrintOutByMonth Macro
'
'
'
Dim FirstDate As Date
Dim LastDate As Date

Application.ScreenUpdating = False

MsgBox ("You will be prompted to enter in a First and Last Date."
Chr(10) & Chr(10) & "This program will print out all records betwee
the two dates including the two dates you enter." & Chr(10) & Chr(10)
"For example, if you want all the records for January 2003 you woul
enter First Date of 01 Jan 2003 and Last Date of 31 Jan 2003")

FirstDate = Application.InputBox("Please Enter the First Date in D
MMM YYYY format: ", "Enter First Date")

LastDate = Application.InputBox("Please Enter the Last Date in D
MMM YYYY format: ", "Enter Last Date")

Selection.AutoFilter Field:=5, Criteria1:="" = " & FirstDate &""
Operator:= xlAnd , Criteria2:="" <= " & LastDate & ""

End Sub

The last line starting with the word Selection is not workin
properly.

It filters all records instead of the records between the first an
last dates.

Any help would be greatly appreciated.

Kind regards,

Chris. :

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default AutoFilter Problem

I posted an example in response to your posting this morning:

http://groups.google.com/groups?&thr...resXSPA M.com

longbow wrote:
Hello,

Could someone please take a look at my VBA code and advise how to make
it work correctly:

Sub PrintOutByMonth()
'
'PrintOutByMonth Macro
'
'
'
Dim FirstDate As Date
Dim LastDate As Date

Application.ScreenUpdating = False

MsgBox ("You will be prompted to enter in a First and Last Date." &
Chr(10) & Chr(10) & "This program will print out all records between
the two dates including the two dates you enter." & Chr(10) & Chr(10) &
"For example, if you want all the records for January 2003 you would
enter First Date of 01 Jan 2003 and Last Date of 31 Jan 2003")

FirstDate = Application.InputBox("Please Enter the First Date in DD
MMM YYYY format: ", "Enter First Date")

LastDate = Application.InputBox("Please Enter the Last Date in DD
MMM YYYY format: ", "Enter Last Date")

Selection.AutoFilter Field:=5, Criteria1:="" = " & FirstDate &"",
Operator:= xlAnd , Criteria2:="" <= " & LastDate & ""

End Sub

The last line starting with the word Selection is not working
properly.

It filters all records instead of the records between the first and
last dates.

Any help would be greatly appreciated.

Kind regards,

Chris. :)


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFilter Problem


Selection.AutoFilter Field:=1, Criteria1:="=" & FistDate
Operator:=xlAnd _
, Criteria2:="<=" & LastDat

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFilter Problem


Thankyou Mudraker for you VBA solution, it works a treat, muc
appreciated.

Cheers,

Chris. :

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

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
AutoFilter Problem Dennis Excel Discussion (Misc queries) 1 October 22nd 08 05:28 AM
Autofilter problem Lawman Excel Discussion (Misc queries) 4 February 28th 08 04:48 PM
autofilter problem Tonso Excel Discussion (Misc queries) 8 November 19th 06 05:22 PM
AutoFilter VBA Problem Michael Link Excel Discussion (Misc queries) 1 July 28th 06 04:41 PM
Problem with Autofilter Jaan Excel Discussion (Misc queries) 6 February 8th 06 06:39 AM


All times are GMT +1. The time now is 05:16 PM.

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"