LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Debug Mode : How to I enter it after executing the nth data row. u473 Excel Programming 1 June 17th 08 02:23 PM
need to modify a macro to prevent it from executing if in wrong area of the sheet Tonso Excel Discussion (Misc queries) 3 February 11th 07 08:00 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
prevent UDF from executing masterphilch Excel Programming 4 January 13th 06 08:40 PM


All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"