#1   Report Post  
Michael
 
Posts: n/a
Default Macro

Excel 2002. I have created a macro that runs a complex autofilter (using
create macro function), and assigned it to a command button. Filter selects
rows with a date either 31/12/2004 or 31/03/2005 ( 168 out of 336 rows )

Sub Period2()
'
' Period2 Macro
' Macro recorded 17/10/2005 by NWCSQARC
'
' Keyboard Shortcut: Ctrl+r
'
Sheets("Last_4_Separate").Select
Selection.AutoFilter Field:=2, Criteria1:="=31/12/2004", Operator:=xlOr, _
Criteria2:="=31/03/2005"
End Sub

If I run the macro using the command button or the short cut key , the
autofilter runs (field arrow turns blue), but it doesn't show any records -
ie all I get is the header row and next available row 338.
If I open the autofilter, select custom and click OK the rows appear -
header row plus matching 168 rows (row number highlighted blue)

I would like the command button/shortcut key to do the same.
  #2   Report Post  
Stefi
 
Posts: n/a
Default Macro

Try to convert date to date literal format using Dateserial function. It
worked for me in a similar case.
Regards,
Stefi


"Michael" wrote:

Excel 2002. I have created a macro that runs a complex autofilter (using
create macro function), and assigned it to a command button. Filter selects
rows with a date either 31/12/2004 or 31/03/2005 ( 168 out of 336 rows )

Sub Period2()
'
' Period2 Macro
' Macro recorded 17/10/2005 by NWCSQARC
'
' Keyboard Shortcut: Ctrl+r
'
Sheets("Last_4_Separate").Select
Selection.AutoFilter Field:=2, Criteria1:="=31/12/2004", Operator:=xlOr, _
Criteria2:="=31/03/2005"
End Sub

If I run the macro using the command button or the short cut key , the
autofilter runs (field arrow turns blue), but it doesn't show any records -
ie all I get is the header row and next available row 338.
If I open the autofilter, select custom and click OK the rows appear -
header row plus matching 168 rows (row number highlighted blue)

I would like the command button/shortcut key to do the same.

  #3   Report Post  
Michael
 
Posts: n/a
Default Macro

Stefi,
Thanks, worked first time



"Stefi" wrote:

Try to convert date to date literal format using Dateserial function. It
worked for me in a similar case.
Regards,
Stefi


"Michael" wrote:

Excel 2002. I have created a macro that runs a complex autofilter (using
create macro function), and assigned it to a command button. Filter selects
rows with a date either 31/12/2004 or 31/03/2005 ( 168 out of 336 rows )

Sub Period2()
'
' Period2 Macro
' Macro recorded 17/10/2005 by NWCSQARC
'
' Keyboard Shortcut: Ctrl+r
'
Sheets("Last_4_Separate").Select
Selection.AutoFilter Field:=2, Criteria1:="=31/12/2004", Operator:=xlOr, _
Criteria2:="=31/03/2005"
End Sub

If I run the macro using the command button or the short cut key , the
autofilter runs (field arrow turns blue), but it doesn't show any records -
ie all I get is the header row and next available row 338.
If I open the autofilter, select custom and click OK the rows appear -
header row plus matching 168 rows (row number highlighted blue)

I would like the command button/shortcut key to do the same.

  #4   Report Post  
Stefi
 
Posts: n/a
Default Macro

Glad to hear that! Thanks for the reply!
Stefi

"Michael" wrote:

Stefi,
Thanks, worked first time



"Stefi" wrote:

Try to convert date to date literal format using Dateserial function. It
worked for me in a similar case.
Regards,
Stefi


"Michael" wrote:

Excel 2002. I have created a macro that runs a complex autofilter (using
create macro function), and assigned it to a command button. Filter selects
rows with a date either 31/12/2004 or 31/03/2005 ( 168 out of 336 rows )

Sub Period2()
'
' Period2 Macro
' Macro recorded 17/10/2005 by NWCSQARC
'
' Keyboard Shortcut: Ctrl+r
'
Sheets("Last_4_Separate").Select
Selection.AutoFilter Field:=2, Criteria1:="=31/12/2004", Operator:=xlOr, _
Criteria2:="=31/03/2005"
End Sub

If I run the macro using the command button or the short cut key , the
autofilter runs (field arrow turns blue), but it doesn't show any records -
ie all I get is the header row and next available row 338.
If I open the autofilter, select custom and click OK the rows appear -
header row plus matching 168 rows (row number highlighted blue)

I would like the command button/shortcut key to do the same.

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
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


All times are GMT +1. The time now is 09:39 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"