Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Event Triggered in Wrong Sheet

Hi,

I am using excel 2003 and have a workbook with 2 sheets and the code below
in "ThisWorkbook".

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Select
If Range("A1") = "" Then
Cancel = True
Range("A1").Select
MsgBox ("Type in the missing data...")
GoTo ExitNow
End If
ExitNow:
End Sub

If I leave cell A1 on Sheet1 blank, then click on Sheet2 and try to print,
it will place the cursor onto Sheet1 cell A1 and if I immediately type a
value and click enter, the value disappears from Sheet1 cell A1 and appears
in Sheet 2 cell A1.

Can anyone help?

--
Thanks, Cassie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Event Triggered in Wrong Sheet

On May 14, 3:30*pm, Cassie wrote:
Hi,

I am using excel 2003 and have a workbook with 2 sheets and the code below
in "ThisWorkbook".

Private Sub Workbook_BeforePrint(Cancel As Boolean)
* * Worksheets("Sheet1").Activate
* * Worksheets("Sheet1").Select
* * If Range("A1") = "" Then
* * * * * * Cancel = True
* * * * * * Range("A1").Select
* * * * * * MsgBox ("Type in the missing data...")
* * * * * * GoTo ExitNow
* * * * End If
ExitNow:
End Sub

If I leave cell A1 on Sheet1 blank, then click on Sheet2 and try to print,
it will place the cursor onto Sheet1 cell A1 and if I immediately type a
value and click enter, the value disappears from Sheet1 cell A1 and appears
in Sheet 2 cell A1.

Can anyone help?

--
Thanks, Cassie


You can only type in a value AFTER you click OK to clear the message
box.
The moment you click OK, you are on the way to ExitNow and back to the
activesheet which is Sheet2
Your input value appears in sheet2 accordingly.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Event Triggered in Wrong Sheet

Cassie,

Your code can be simplified to that below but I can't see how your code (or
mine) would cause what you describe. Do you have any other code in the
workbook?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Sheets("Sheet1").Range("A1") = "" Then
Cancel = True
Application.Goto Sheets("Sheet1").Range("A1")
MsgBox ("Type in the missing data...")
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Cassie" wrote:

Hi,

I am using excel 2003 and have a workbook with 2 sheets and the code below
in "ThisWorkbook".

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Select
If Range("A1") = "" Then
Cancel = True
Range("A1").Select
MsgBox ("Type in the missing data...")
GoTo ExitNow
End If
ExitNow:
End Sub

If I leave cell A1 on Sheet1 blank, then click on Sheet2 and try to print,
it will place the cursor onto Sheet1 cell A1 and if I immediately type a
value and click enter, the value disappears from Sheet1 cell A1 and appears
in Sheet 2 cell A1.

Can anyone help?

--
Thanks, Cassie

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 triggered in Excel's cell by DDE albertleng Excel Programming 3 July 8th 08 04:59 AM
Worksheet_Change event not triggered as expected IanKR Excel Programming 4 October 17th 07 07:39 PM
Macro triggered by an event Mekinnik Excel Programming 3 October 1st 07 07:46 PM
Event triggered by paste [email protected] Excel Programming 3 December 14th 05 09:03 PM
Macro triggered by an event AussieAVguy Excel Discussion (Misc queries) 2 June 16th 05 05:51 AM


All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"