#1   Report Post  
Posted to microsoft.public.excel.misc
Frank Xia
 
Posts: n/a
Default Event doesn't fire

Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is there any
condition apply to this event?

Any help appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Event doesn't fire

Frank,

Is the code in the ThisWorkbook code module? It must be in that
module, not a regular code module, for the code to work. Also,
ensure that Application.EnableEvents is True. In the VBA Editor,
press CTRL+G to display the Immediate window, and type the
following and press Enter

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Frank Xia" wrote in message
...
Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is
there any
condition apply to this event?

Any help appreciated!



  #3   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Event doesn't fire

"Chip Pearson" wrote in message

Is the code in the ThisWorkbook code module?


This is miswritten. The code must be in a sheet module, not the
ThisWorkbook module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Chip Pearson" wrote in message
...
Frank,

Is the code in the ThisWorkbook code module? It must be in that
module, not a regular code module, for the code to work. Also,
ensure that Application.EnableEvents is True. In the VBA
Editor, press CTRL+G to display the Immediate window, and type
the following and press Enter

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Frank Xia" wrote in
message
...
Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is
there any
condition apply to this event?

Any help appreciated!





  #4   Report Post  
Posted to microsoft.public.excel.misc
Frank Xia
 
Posts: n/a
Default Event doesn't fire

Thank you very much! It helped!

"Chip Pearson" wrote:

Frank,

Is the code in the ThisWorkbook code module? It must be in that
module, not a regular code module, for the code to work. Also,
ensure that Application.EnableEvents is True. In the VBA Editor,
press CTRL+G to display the Immediate window, and type the
following and press Enter

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Frank Xia" wrote in message
...
Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is
there any
condition apply to this event?

Any help appreciated!




  #5   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Event doesn't fire

You code works fine, but must be put in worksheet code.

Right-click any tab
Select view code
Enter your code
--
Gary's Student


"Frank Xia" wrote:

Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is there any
condition apply to this event?

Any help appreciated!



  #6   Report Post  
Posted to microsoft.public.excel.misc
Frank Xia
 
Posts: n/a
Default Event doesn't fire

Thanks a lot! This helps and I learned!

"Gary''s Student" wrote:

You code works fine, but must be put in worksheet code.

Right-click any tab
Select view code
Enter your code
--
Gary's Student


"Frank Xia" wrote:

Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is there any
condition apply to this event?

Any help appreciated!

  #7   Report Post  
Posted to microsoft.public.excel.misc
Kevin Vaughn
 
Posts: n/a
Default Event doesn't fire

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "ok"
End Sub
Worked for me. I wonder why yours says Excel.range and mine just says range?

--
Kevin Vaughn


"Frank Xia" wrote:

Hi,
I am trying a simple worksheet change event as following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox ("ok")
End sub

but it does not fire and I can not the msgbox shown up. Is there any
condition apply to this event?

Any help appreciated!

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
Unable to Start Excel Event ID 2001 Melih Excel Discussion (Misc queries) 3 January 22nd 06 11:18 PM
Using excel to manage event - ANY input deeply appreciated! :-) ojbelboe Excel Discussion (Misc queries) 3 January 18th 06 10:21 PM
how do I make a word typed in a cell go to a specific cell in anot Lmatarazzo Excel Discussion (Misc queries) 3 April 21st 05 04:29 AM
Excel Automation SelectionChange event cpotts Excel Discussion (Misc queries) 1 December 20th 04 05:15 PM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


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