Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - trigger sheet event BEFORE deactivating

Hi All

I want to inform a user of incomplete cells if they attempt to move to a
different worksheet.

The Worksheet_Deactivate event takes the focus away from the current sheet
before running the code. Is there another event I can use that runs before
displaying the next sheet?

Thanks in advance

Trevor Williams
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2002 - trigger sheet event BEFORE deactivating

Hi Trevor,

What you are looking for is a BeforeDeactivate event with a Cancel, and
there isn't one. Workaround is to reactivate the sheet if necessary

Private Sub Worksheet_Deactivate()
If Len(Range("A1")) = 0 Then ' empty cell A1
On Error GoTo errH:
' if necessary disable events
Application.EnableEvents = False
Me.Activate
Application.Goto Range("A1"), True
MsgBox "Complete cell A1"
End If
errH:
Application.EnableEvents = True
End Sub

Regards,
Peter T

"Trevor Williams" wrote in
message ...
Hi All

I want to inform a user of incomplete cells if they attempt to move to a
different worksheet.

The Worksheet_Deactivate event takes the focus away from the current sheet
before running the code. Is there another event I can use that runs

before
displaying the next sheet?

Thanks in advance

Trevor Williams



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default XL2002 - trigger sheet event BEFORE deactivating

I don't think so. We need a 'before deactivate' event with a cancel option.
As a result of this limitation I hide worksheet tabs and make users use my
buttons or menus instead.

--
Jim
"Trevor Williams" wrote in
message ...
| Hi All
|
| I want to inform a user of incomplete cells if they attempt to move to a
| different worksheet.
|
| The Worksheet_Deactivate event takes the focus away from the current sheet
| before running the code. Is there another event I can use that runs
before
| displaying the next sheet?
|
| Thanks in advance
|
| Trevor Williams


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - trigger sheet event BEFORE deactivating

Hi Peter,

That's what I thought. Bit of an oversight on MS behalf. (perhaps it's in
2007)
I'm using navigation controls on my sheets so I'm going with Jim Rech's
option.

Thanks for the response.

"Peter T" wrote:

Hi Trevor,

What you are looking for is a BeforeDeactivate event with a Cancel, and
there isn't one. Workaround is to reactivate the sheet if necessary

Private Sub Worksheet_Deactivate()
If Len(Range("A1")) = 0 Then ' empty cell A1
On Error GoTo errH:
' if necessary disable events
Application.EnableEvents = False
Me.Activate
Application.Goto Range("A1"), True
MsgBox "Complete cell A1"
End If
errH:
Application.EnableEvents = True
End Sub

Regards,
Peter T

"Trevor Williams" wrote in
message ...
Hi All

I want to inform a user of incomplete cells if they attempt to move to a
different worksheet.

The Worksheet_Deactivate event takes the focus away from the current sheet
before running the code. Is there another event I can use that runs

before
displaying the next sheet?

Thanks in advance

Trevor Williams




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - trigger sheet event BEFORE deactivating

Thanks Jim

I'm using nav buttons so will bolt it onto them.

Trevor

"Jim Rech" wrote:

I don't think so. We need a 'before deactivate' event with a cancel option.
As a result of this limitation I hide worksheet tabs and make users use my
buttons or menus instead.

--
Jim
"Trevor Williams" wrote in
message ...
| Hi All
|
| I want to inform a user of incomplete cells if they attempt to move to a
| different worksheet.
|
| The Worksheet_Deactivate event takes the focus away from the current sheet
| before running the code. Is there another event I can use that runs
before
| displaying the next sheet?
|
| Thanks in advance
|
| Trevor Williams





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2002 - trigger sheet event BEFORE deactivating

You may need to trap Ctrl-PageUp/Down with too that approach

Regards,
Peter T


"Trevor Williams" wrote in
message ...
Hi Peter,

That's what I thought. Bit of an oversight on MS behalf. (perhaps it's

in
2007)
I'm using navigation controls on my sheets so I'm going with Jim Rech's
option.

Thanks for the response.

"Peter T" wrote:

Hi Trevor,

What you are looking for is a BeforeDeactivate event with a Cancel, and
there isn't one. Workaround is to reactivate the sheet if necessary

Private Sub Worksheet_Deactivate()
If Len(Range("A1")) = 0 Then ' empty cell A1
On Error GoTo errH:
' if necessary disable events
Application.EnableEvents = False
Me.Activate
Application.Goto Range("A1"), True
MsgBox "Complete cell A1"
End If
errH:
Application.EnableEvents = True
End Sub

Regards,
Peter T

"Trevor Williams" wrote in
message ...
Hi All

I want to inform a user of incomplete cells if they attempt to move to

a
different worksheet.

The Worksheet_Deactivate event takes the focus away from the current

sheet
before running the code. Is there another event I can use that runs

before
displaying the next sheet?

Thanks in advance

Trevor Williams






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
Event Trigger lobo Excel Programming 5 December 16th 05 08:33 PM
Deactivating Multipage Change Event [email protected] Excel Programming 0 September 9th 04 03:13 AM
Deactivating Multipage Change Event [email protected] Excel Programming 2 September 9th 04 02:49 AM
Trigger Event Todd Huttenstine Excel Programming 2 July 14th 04 06:50 PM
Format Event Trigger (XL2002) Ronald Dodge Excel Programming 2 April 27th 04 09:48 PM


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