View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary L Brown Gary L Brown is offline
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.