J
John Keith
I have the following worksheet change event macro and it works pretty
much as desired (description of macro at bottom of posting).
The macro is triggered as expected when the Enter key is pressed.
But..... the macro is also triggered when ALT-Enter is pressed, when I
want to enter a line feed into the text going into a cell but I'm not
done entering all of the text yet for that cell.
Is there a way I can get the macro to not trigger on the ALT-Enter key
event?
Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.row
b = Target.Column
If b < 19 Or b > 28 Then Exit Sub
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False ' turn off to prevent looping
Cells(a, 2) = Format(Now(), "mm/dd/yy")
If b = 4 Then GoTo do_not_update
Current_Text = Cells(a, 4)
If Len(Current_Text) > 0 Then Current_Text = Chr(10) &
Current_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Current_Text
Application.EnableEvents = True
End Sub
What the macro does:
If data is entered into cells in columns 19 thorugh 27 then add a text
note to the cell in column 4 of the same row indicating that column T
changed (for example).
John Keith
(e-mail address removed)
much as desired (description of macro at bottom of posting).
The macro is triggered as expected when the Enter key is pressed.
But..... the macro is also triggered when ALT-Enter is pressed, when I
want to enter a line feed into the text going into a cell but I'm not
done entering all of the text yet for that cell.
Is there a way I can get the macro to not trigger on the ALT-Enter key
event?
Private Sub Worksheet_Change(ByVal Target As Range)
a = Target.row
b = Target.Column
If b < 19 Or b > 28 Then Exit Sub
ColumnLetter = Left(Cells(1, b).Address(0, 0), 2 + (b <= 26))
Application.EnableEvents = False ' turn off to prevent looping
Cells(a, 2) = Format(Now(), "mm/dd/yy")
If b = 4 Then GoTo do_not_update
Current_Text = Cells(a, 4)
If Len(Current_Text) > 0 Then Current_Text = Chr(10) &
Current_Text
New_Text = " column " & ColumnLetter & " changed"
Cells(a, 4) = Format(Now(), "m/d/yy") & New_Text & Current_Text
Application.EnableEvents = True
End Sub
What the macro does:
If data is entered into cells in columns 19 thorugh 27 then add a text
note to the cell in column 4 of the same row indicating that column T
changed (for example).
John Keith
(e-mail address removed)