#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default AUTOMATIC EXECUTION

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?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default AUTOMATIC EXECUTION

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

On Fri, 28 Dec 2007 12:51:03 -0800, VB_User
wrote:

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?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default AUTOMATIC EXECUTION

hi
use the worksheet_selectionchange event.
This will cause code to run whenever the cells on the sheet change.

Regards
FSt1

"VB_User" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default AUTOMATIC EXECUTION


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.

"FSt1" wrote:

hi
use the worksheet_selectionchange event.
This will cause code to run whenever the cells on the sheet change.

Regards
FSt1

"VB_User" wrote:

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?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default AUTOMATIC EXECUTION

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.

"Gord Dibben" wrote:

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

On Fri, 28 Dec 2007 12:51:03 -0800, VB_User
wrote:

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?





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default AUTOMATIC EXECUTION

Apologies.

I usually add instructions on where to place the code.

An oversight this time.


Gord

On Fri, 28 Dec 2007 15:00:00 -0800, VB_User
wrote:

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.

"Gord Dibben" wrote:

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

On Fri, 28 Dec 2007 12:51:03 -0800, VB_User
wrote:

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?




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
Help - VBA Code execution in Excel Luis[_2_] New Users to Excel 2 September 10th 07 03:14 AM
Macro Execution C Brandt Excel Discussion (Misc queries) 2 July 13th 07 07:23 AM
How to automatic calculation and macro execution between 3 workbooks? c Excel Worksheet Functions 1 July 22nd 05 05:38 AM
function execution matty_g Excel Worksheet Functions 11 June 9th 05 10:13 PM
function execution matty_g Excel Worksheet Functions 2 June 9th 05 12:05 AM


All times are GMT +1. The time now is 07:22 PM.

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"