Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Need MACRO to search for date

Is there a way to have a macro look in an excel database that is sorted by
date and find all the records that have a date that is within the current
month, then select only those rows and certain columns, e.g., columns D
through K and set the print area using that range? The number of records
will be different each month, but they will always be contigous.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Need MACRO to search for date

1) Set Auto-Filter on. [Only needs to be done once.]
2) Set your print range to D:K [Only needs to be done once.]
3) Figure out which column # you are using for your filter (example uses
Column C in the macro for the 'Field') [Only needs to be done once.]

4) Run a macro similar to...

Sub FilterMe()
Dim strStartDate As String, strEndDate As String

strStartDate = _
Application.InputBox(Prompt:="Enter Start Date: ", _
Title:="Filter Period...Syntax 'dd-mmm-yyyy'", Type:=2) '2=text

strEndDate = _
Application.InputBox(Prompt:="Enter End Date: ", _
Title:="Filter Period...Syntax 'dd-mmm-yyyy'", Type:=2) '2=text

Selection.AutoFilter Field:=3, Criteria1:="=" & _
strStartDate, Operator:=xlAnd, Criteria2:="<=" & strEndDate
End Sub

5) Print


HTH,
--
Gary Brown

If this post was helpful, please click the ''''Yes'''' button next to
''''Was this Post Helpfull to you?".


"Loris" wrote:

Is there a way to have a macro look in an excel database that is sorted by
date and find all the records that have a date that is within the current
month, then select only those rows and certain columns, e.g., columns D
through K and set the print area using that range? The number of records
will be different each month, but they will always be contigous.

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
Date Search Chey Excel Discussion (Misc queries) 2 April 17th 09 11:35 PM
how to search by date MV Excel Discussion (Misc queries) 3 September 10th 07 02:44 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM
Search by Date Mickey[_3_] Excel Programming 2 August 25th 03 10:41 PM


All times are GMT +1. The time now is 02:50 PM.

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

About Us

"It's about Microsoft Excel"