AUTOMATIC EXECUTION

  • Thread starter Thread starter VB_User
  • Start date Start date
V

VB_User

I would like to execute a macro every time the "Enter" key is depressed (or
an entry is made to an Excel cell). Is there a way to do this with a special
macro (Visual Basic)? Or, is there another way?
 
A particular cell or a range of cells or?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in any cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
With Target
If .Value <> "" Then
yourmacroname
End If
End With
End If
enditall:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP
 
hi
use the worksheet_selectionchange event.
This will cause code to run whenever the cells on the sheet change.

Regards
FSt1
 
Somehow nothing works. I insert the suggested subroutine, but it never
executes. I've seen the same suggestion, with commands included, in other
posts - but I get no response. Am I using the wrong version of Visual Basic?
I'm using Excel 2003 and the VB that comes with it.
 
I finally figured it out (it wasn't obvious) - that I must enter the "Change"
macro in the sheet rather than for the workbook!!!

Thank you. It's just what I've been looking for for the last few months.
 
Apologies.

I usually add instructions on where to place the code.

An oversight this time.


Gord
 
Back
Top