Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Cofi Sais
 
Posts: n/a
Default Beginners Macros

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 LAST SEEN
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 where I am prompted for the €śfrom€ť and €śto€ť dates.

Thanks in advance



--
Tony
  #2   Report Post  
Kassie
 
Posts: n/a
Default

Hi Cofi
You need to undo your filter, before you can run it again. You are now
filtering an already filtered selection.

"Cofi Sais" wrote:

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 LAST SEEN
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 where I am prompted for the €śfrom€ť and €śto€ť dates.

Thanks in advance



--
Tony

  #3   Report Post  
Cofi Sais
 
Posts: n/a
Default

Kassie
Have tried that but still have the same problem.Even tried recording another
macro to undo the filter!
Thanks for your response.Any other ideas?
--
Tony


"Kassie" wrote:

Hi Cofi
You need to undo your filter, before you can run it again. You are now
filtering an already filtered selection.

"Cofi Sais" wrote:

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 LAST SEEN
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 where I am prompted for the €śfrom€ť and €śto€ť dates.

Thanks in advance



--
Tony

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
Protect macros? JulieD Excel Discussion (Misc queries) 6 August 25th 05 08:38 PM
sharing macros fabulousk Excel Discussion (Misc queries) 3 March 7th 05 10:05 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM
The available macros list in XL; how to suppress filename from showing KR Excel Discussion (Misc queries) 1 January 10th 05 07:20 PM


All times are GMT +1. The time now is 08:04 AM.

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"