ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Change(ByVal... not working now (https://www.excelbanter.com/excel-programming/433471-worksheet_change-byval-not-working-now.html)

John Keith

Worksheet_Change(ByVal... not working now
 
I have the following code in a worksheet and it worked fine at the
time I first played with it. I haven't touched the workbook for a
while and now the macro is never executed. I put a breakpoint in the
code and the breakpoint is never reached. Have I done something to
disable the ability to trigger on value changes?

(I think the content and action of the code itself is not the issue
and what I have posted is actually simplified to minimize the post.
The fact remains that it appears that the macro is never invoked.)

Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.Row
b = Target.Column
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False
Cells(a, 2) = Format(Now(), "mm/dd/yy")
Current_Text = Cells(a, 4)
If Len(Cur_Text) 0 Then Cur_Text = Chr(10) & Cur_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Cur_Text
Application.EnableEvents = True
End Sub

TIA



John Keith


Don Guillett

Worksheet_Change(ByVal... not working now
 
I just installed your macro in the sheet code and changed a cell in col a
and got
2 9/11/2009 9/11/09 column A changed


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John Keith" wrote in message
...
I have the following code in a worksheet and it worked fine at the
time I first played with it. I haven't touched the workbook for a
while and now the macro is never executed. I put a breakpoint in the
code and the breakpoint is never reached. Have I done something to
disable the ability to trigger on value changes?

(I think the content and action of the code itself is not the issue
and what I have posted is actually simplified to minimize the post.
The fact remains that it appears that the macro is never invoked.)

Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.Row
b = Target.Column
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False
Cells(a, 2) = Format(Now(), "mm/dd/yy")
Current_Text = Cells(a, 4)
If Len(Cur_Text) 0 Then Cur_Text = Chr(10) & Cur_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Cur_Text
Application.EnableEvents = True
End Sub

TIA



John Keith



John Keith

Worksheet_Change(ByVal... not working now
 
Don,

Yes, that's exactly what it used to do for me (well, simplified as I
noted.) For some reason the code does not execute on my workbook.
Strange.

On Fri, 11 Sep 2009 11:19:36 -0500, "Don Guillett"
wrote:

I just installed your macro in the sheet code and changed a cell in col a
and got
2 9/11/2009 9/11/09 column A changed


John Keith


Jim Thomlinson

Worksheet_Change(ByVal... not working now
 
Ensure that your events are not disabled...

Sub ResetEvents
Application.EnableEvents = True
end sub

Events is a persistent setting. If you switch it off the only way to
reactiveate it is to do so via code...
--
HTH...

Jim Thomlinson


"John Keith" wrote:

I have the following code in a worksheet and it worked fine at the
time I first played with it. I haven't touched the workbook for a
while and now the macro is never executed. I put a breakpoint in the
code and the breakpoint is never reached. Have I done something to
disable the ability to trigger on value changes?

(I think the content and action of the code itself is not the issue
and what I have posted is actually simplified to minimize the post.
The fact remains that it appears that the macro is never invoked.)

Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.Row
b = Target.Column
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False
Cells(a, 2) = Format(Now(), "mm/dd/yy")
Current_Text = Cells(a, 4)
If Len(Cur_Text) 0 Then Cur_Text = Chr(10) & Cur_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Cur_Text
Application.EnableEvents = True
End Sub

TIA



John Keith



Don Guillett

Worksheet_Change(ByVal... not working now
 

Or leave and come back
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim Thomlinson" wrote in message
...
Ensure that your events are not disabled...

Sub ResetEvents
Application.EnableEvents = True
end sub

Events is a persistent setting. If you switch it off the only way to
reactiveate it is to do so via code...
--
HTH...

Jim Thomlinson


"John Keith" wrote:

I have the following code in a worksheet and it worked fine at the
time I first played with it. I haven't touched the workbook for a
while and now the macro is never executed. I put a breakpoint in the
code and the breakpoint is never reached. Have I done something to
disable the ability to trigger on value changes?

(I think the content and action of the code itself is not the issue
and what I have posted is actually simplified to minimize the post.
The fact remains that it appears that the macro is never invoked.)

Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.Row
b = Target.Column
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False
Cells(a, 2) = Format(Now(), "mm/dd/yy")
Current_Text = Cells(a, 4)
If Len(Cur_Text) 0 Then Cur_Text = Chr(10) & Cur_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Cur_Text
Application.EnableEvents = True
End Sub

TIA



John Keith




John Keith

Worksheet_Change(ByVal... not working now
 
On Fri, 11 Sep 2009 09:53:01 -0700, Jim Thomlinson
wrote:

Ensure that your events are not disabled...

Sub ResetEvents
Application.EnableEvents = True
end sub

Events is a persistent setting. If you switch it off the only way to
reactiveate it is to do so via code...

Jim,

Thanks, I think somehow during the testing this mode must have been
been left in the wrong state.



John Keith



All times are GMT +1. The time now is 03:18 AM.

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