Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hi all
Is it possible to run a macro by entering data in a cell, and pressing Enter? Many thanks George |
#2
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Event Macro | Excel Discussion (Misc queries) | |||
Macro triggered by an event | Excel Discussion (Misc queries) | |||
Help with macro looping and color query function | Excel Discussion (Misc queries) | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) |