ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sub Worksheet_Change (https://www.excelbanter.com/excel-discussion-misc-queries/165909-sub-worksheet_change.html)

Matt

Sub Worksheet_Change
 
I am trying to do something like =IF(A110,RunMacro). I realize that
this cannot be done but there is a generic syntax that will basically
do this:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value 10 Then
MsgBox "Put Your Code Here"
End If
End If
End Sub

The trouble I'm having is that the message box does not appear if I
type "11" in A1 and press enter. The message box only appears when I
click back on A1 after having already typed "11".

Am I missing something?


Jim Rech[_2_]

Sub Worksheet_Change
 
Your code runs fine for me. It sounds like your code is in sub
Worksheet_SelectionChange. No chance you copied the wrong code into your
post?

--
Jim
"Matt" wrote in message
ps.com...
|I am trying to do something like =IF(A110,RunMacro). I realize that
| this cannot be done but there is a generic syntax that will basically
| do this:
|
| Private Sub Worksheet_Change(ByVal Target As Excel.Range)
| If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
| If Target.Value 10 Then
| MsgBox "Put Your Code Here"
| End If
| End If
| End Sub
|
| The trouble I'm having is that the message box does not appear if I
| type "11" in A1 and press enter. The message box only appears when I
| click back on A1 after having already typed "11".
|
| Am I missing something?
|



John Bundy

Sub Worksheet_Change
 
I copied and pasted your code and it works for me. xl2k3
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Matt" wrote:

I am trying to do something like =IF(A110,RunMacro). I realize that
this cannot be done but there is a generic syntax that will basically
do this:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value 10 Then
MsgBox "Put Your Code Here"
End If
End If
End Sub

The trouble I'm having is that the message box does not appear if I
type "11" in A1 and press enter. The message box only appears when I
click back on A1 after having already typed "11".

Am I missing something?



Matt

Sub Worksheet_Change
 
Thats odd. Works for me too now (??)


All times are GMT +1. The time now is 04:02 AM.

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