Beginners Macros

C

Cofi Sais

A relative novice with Excel, I use a number of worksheets for recording
amongst other things, when various items of plant and equipment are due for
test and inspection. As an initial experiment (I need to expand it in due
course to do more complicated filters) I have recorded a macro to filter out
items due for test within given dates and print out the result using the
AutoFilter function. Sample data below:

DESCRIPTION Date Due
Yale Lever Hoist 05/08/04
Yale Lever Hoist 05/08/04
Yale Lever Hoist 06/08/04
Winch Rope 03/02/05
The macro is as follows:


Sub Sort()
'
' Sort Macro
' Macro recorded 23/06/2005 by Tony
'
' Keyboard Shortcut: Ctrl+s
'
Range("G4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=7, Criteria1:=">=23/06/2005",
Operator:=xlAnd _
, Criteria2:="<=05/08/2005"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.ShowAllData
Selection.AutoFilter
End Sub

The first time I run the macro it works fine, however if I try to run it a
second time it only prints out the coloumn headings.

I am sure the solution is obvious, but not to me. Can anyone please point me
in the right direction. In the longer term I would like to have “selectionâ€
boxes or buttons where I am prompted for the “from†and “to†dates.

Thanks in advance
 
D

Damiaan

This is an Acces group with access people. So, import your data in Access
and make a simple query.

If you want to stick to Excel, the simpliest solution will be to re-record
your macro at a moment the autoflter is ON.
 
C

Cofi Sais

Damiaan
Sorry about that-I am new to usergroups and didn't notice.Thanks for your
repsonse and help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top