Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Workbook BeforeClose Event Error

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Current Issues Log").Select
Selection.AutoFilter Field:=4, Criteria1:="<Closed", Operator:=xlAnd
End Sub

I am using the above to autofilter my sheet before close. I am using this
identical code in two workbooks, which have the same worksheet names. It
works fine when I close one workbook at a time, but if I try to shut down
excel with both books open, I get a runtime error '1004' select method of
worksheet class failed.

Is there a way round this?

Regards
Dylan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Workbook BeforeClose Event Error

Hello
Change
Sheets("Current Issues Log").Select

To
Thisworkbook.Worksheets("Current Issues Log").Select

But you don't need to select your sheet, so you may consider using something
like:
Thisworkbook.Worksheets("Current Issues Log").Range("A1") _
..AutoFilter Field:=4, Criteria1:="<Closed", Operator:=xlAnd

HTH
Cordially
Pascal


"dd" <dd.dd a écrit dans le message de news:
...
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Current Issues Log").Select
Selection.AutoFilter Field:=4, Criteria1:="<Closed", Operator:=xlAnd
End Sub

I am using the above to autofilter my sheet before close. I am using this
identical code in two workbooks, which have the same worksheet names. It
works fine when I close one workbook at a time, but if I try to shut down
excel with both books open, I get a runtime error '1004' select method of
worksheet class failed.

Is there a way round this?

Regards
Dylan




  #3   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Workbook BeforeClose Event Error

Pascal

Thank you

Kind Regards
Dylan

"papou" wrote in message
...
Hello
Change
Sheets("Current Issues Log").Select

To
Thisworkbook.Worksheets("Current Issues Log").Select

But you don't need to select your sheet, so you may consider using something
like:
Thisworkbook.Worksheets("Current Issues Log").Range("A1") _
..AutoFilter Field:=4, Criteria1:="<Closed", Operator:=xlAnd

HTH
Cordially
Pascal


"dd" <dd.dd a écrit dans le message de news:
...
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Current Issues Log").Select
Selection.AutoFilter Field:=4, Criteria1:="<Closed", Operator:=xlAnd
End Sub

I am using the above to autofilter my sheet before close. I am using this
identical code in two workbooks, which have the same worksheet names. It
works fine when I close one workbook at a time, but if I try to shut down
excel with both books open, I get a runtime error '1004' select method of
worksheet class failed.

Is there a way round this?

Regards
Dylan





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
BeforeClose event help [email protected] Excel Programming 3 June 22nd 07 10:02 AM
BeforeClose Event JT Excel Programming 2 April 10th 07 03:52 PM
Is workbook beforeclose event the best place to do this? Barb Reinhardt Excel Programming 1 October 12th 06 02:50 PM
How to get out of BeforeClose event without closing? 42N83W Excel Programming 4 March 11th 05 05:33 PM
BeforeClose event - Savings Mike[_40_] Excel Programming 3 September 24th 03 11:33 AM


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