Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
George Gee
 
Posts: n/a
Default 'Event' macro

Hi all

Is it possible to run a macro by entering data in a cell, and pressing
Enter?

Many thanks

George


  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--

HTH

RP
(remove nothere from the email address if mailing direct)


"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and pressing
Enter?

Many thanks

George




  #3   Report Post  
George Gee
 
Posts: n/a
Default

Many thanks.

This may not be what I am looking for!
I have 38 cells that I will be entering a football result into (one each
week).
Range (N3:N40).
I have 38 different macros already written, to assign.

I could assign them to 38 buttons or graphics, but do not fancy making and
assigning 38 of them!
I thought maybe a particular macro could be assigned to a cell
and could be run by entering the football score into the cell.

Any comment
Thanks again.

George







Bob Phillips wrote:
It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and
pressing Enter?

Many thanks

George



  #4   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Private Sub Worksheet_Change(ByVal Target As Range)

if target.address = "$A$1"
call macro1
end if
End Sub

is a simple example. Use the Select Case for all 38 conditions.

Mangesh



"George Gee" wrote in message
...
Many thanks.

This may not be what I am looking for!
I have 38 cells that I will be entering a football result into (one each
week).
Range (N3:N40).
I have 38 different macros already written, to assign.

I could assign them to 38 buttons or graphics, but do not fancy making and
assigning 38 of them!
I thought maybe a particular macro could be assigned to a cell
and could be run by entering the football score into the cell.

Any comment
Thanks again.

George







Bob Phillips wrote:
It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and
pressing Enter?

Many thanks

George





  #5   Report Post  
George Gee
 
Posts: n/a
Default

Mangeshh

Thanks for that.

I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Target.Address = "$N$3" Then
Call AstonAway
End If
End Sub

However, as soon as I select the cell the macro runs.
I need to be able to select the cell, input the data,
*then* run the macro.

Am I doing something wrong?

George Gee


Mangesh Yadav wrote:
Private Sub Worksheet_Change(ByVal Target As Range)

if target.address = "$A$1"
call macro1
end if
End Sub

is a simple example. Use the Select Case for all 38 conditions.

Mangesh



"George Gee" wrote in message
...
Many thanks.

This may not be what I am looking for!
I have 38 cells that I will be entering a football result into (one
each week).
Range (N3:N40).
I have 38 different macros already written, to assign.

I could assign them to 38 buttons or graphics, but do not fancy
making and assigning 38 of them!
I thought maybe a particular macro could be assigned to a cell
and could be run by entering the football score into the cell.

Any comment
Thanks again.

George







Bob Phillips wrote:
It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and
pressing Enter?

Many thanks

George





  #6   Report Post  
George Gee
 
Posts: n/a
Default

Update

I have thought of a workaround.

I have made the target cell, the cell to the right of the one
in which I am inputting the data, input the data, and press 'Enter'
this selects the cell to the right, and runs the macro.

Unless there is a better solution, I will stick with this.

Thanks for your help so far.

George Gee


George Gee wrote:
Mangeshh

Thanks for that.

I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Target.Address = "$N$3" Then
Call AstonAway
End If
End Sub

However, as soon as I select the cell the macro runs.
I need to be able to select the cell, input the data,
*then* run the macro.

Am I doing something wrong?

George Gee


Mangesh Yadav wrote:
Private Sub Worksheet_Change(ByVal Target As Range)

if target.address = "$A$1"
call macro1
end if
End Sub

is a simple example. Use the Select Case for all 38 conditions.

Mangesh



"George Gee" wrote in message
...
Many thanks.

This may not be what I am looking for!
I have 38 cells that I will be entering a football result into (one
each week).
Range (N3:N40).
I have 38 different macros already written, to assign.

I could assign them to 38 buttons or graphics, but do not fancy
making and assigning 38 of them!
I thought maybe a particular macro could be assigned to a cell
and could be run by entering the football score into the cell.

Any comment
Thanks again.

George







Bob Phillips wrote:
It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and
pressing Enter?

Many thanks

George



  #7   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Sorry,

should be

Worksheet_Change


Mangesh




"George Gee" wrote in message
...
Mangeshh

Thanks for that.

I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Target.Address = "$N$3" Then
Call AstonAway
End If
End Sub

However, as soon as I select the cell the macro runs.
I need to be able to select the cell, input the data,
*then* run the macro.

Am I doing something wrong?

George Gee


Mangesh Yadav wrote:
Private Sub Worksheet_Change(ByVal Target As Range)

if target.address = "$A$1"
call macro1
end if
End Sub

is a simple example. Use the Select Case for all 38 conditions.

Mangesh



"George Gee" wrote in message
...
Many thanks.

This may not be what I am looking for!
I have 38 cells that I will be entering a football result into (one
each week).
Range (N3:N40).
I have 38 different macros already written, to assign.

I could assign them to 38 buttons or graphics, but do not fancy
making and assigning 38 of them!
I thought maybe a particular macro could be assigned to a cell
and could be run by entering the football score into the cell.

Any comment
Thanks again.

George







Bob Phillips wrote:
It is

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





"George Gee" wrote in message
...
Hi all

Is it possible to run a macro by entering data in a cell, and
pressing Enter?

Many thanks

George





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
Event Macro stevepain Excel Discussion (Misc queries) 6 August 5th 05 05:11 AM
Macro triggered by an event AussieAVguy Excel Discussion (Misc queries) 2 June 16th 05 05:51 AM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


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

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

About Us

"It's about Microsoft Excel"