Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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?


Reply
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
Indication that there is a # cell value in the range avi Excel Programming 2 January 10th 08 05:30 PM
Cell has focus but no indication that it does. Jacob Excel Programming 2 May 4th 07 12:58 AM
screen position indication? nastech Excel Discussion (Misc queries) 1 August 17th 06 07:55 PM
Autofilter indication when being used Cheese Excel Discussion (Misc queries) 1 July 8th 05 07:18 AM
time indication bar Jos reulen Excel Programming 0 November 24th 03 10:05 AM


All times are GMT +1. The time now is 03:16 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"