Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prevent event macro from executing on ALT-Enter
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA Debug Mode : How to I enter it after executing the nth data row. | Excel Programming | |||
need to modify a macro to prevent it from executing if in wrong area of the sheet | Excel Discussion (Misc queries) | |||
MsgBox in Enter event causes combobox not to run Change event | Excel Programming | |||
prevent UDF from executing | Excel Programming |