ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Event doesn't fire (https://www.excelbanter.com/excel-discussion-misc-queries/71003-event-doesnt-fire.html)

Frank Xia

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!

Gary''s Student

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!


Chip Pearson

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!




Chip Pearson

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!






Kevin Vaughn

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!


Frank Xia

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!


Frank Xia

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!






All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com