![]() |
keyboard press indication
Hi,
i need the macro to distinguish between a user press and a macro input is it posible to have a function that indicate a keyboard press? |
keyboard press indication
I don't think you can check on individual keystrokes, but below is a method
I posted in the past that will allow you to decide if the input came from the user or a macro. Create a Public Boolean variable in a Module, set it to True at the start of **all** your macros, check the variable in the Change event and, at the end of the change event, set the variable back to False. Here is a very simple example... In a Module =========================== Public InModule As Boolean In a Macro =========================== Sub MyMacro() InModule = True Range("A1").Value = "Where did I come from?" ' ' Actual code goes here ' End Sub In Worksheet Change event =========================== Private Sub Worksheet_Change(ByVal Target As Range) If Not InModule Then MsgBox "Cell was **NOT** changed by a macro" ' ' Actual code goes here ' Else MsgBox "Cell changed by a macro" ' ' Actual code goes here ' End If InModule = False End Sub Try typing an entry into a cell and then run the MyMacro macro. -- Rick (MVP - Excel) "thread" wrote in message ... Hi, i need the macro to distinguish between a user press and a macro input is it posible to have a function that indicate a keyboard press? |
All times are GMT +1. The time now is 12:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com