ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a macro when there is a given cell entry (https://www.excelbanter.com/excel-programming/376413-running-macro-when-there-given-cell-entry.html)

[email protected]

Running a macro when there is a given cell entry
 
I am trying to get my sheet to automatically run a macro, when a user
inputs the character "Y".

It's reasonably straightforward to tie a macro in with a button press
but I am not sure if it's as easy to do with a specific cell entry.

I'm sure there should be a way to do this. Ideas?


Carim

Running a macro when there is a given cell entry
 
Hi,

Pretty simple with an event macro ...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "Y" Then
Application.Run ("yourmacro")
End If
End Sub

HTH
Carim


Jim Rech

Running a macro when there is a given cell entry
 
If Target.Value = "Y" Then
Application.Run ("yourmacro")
End If

I don't think there is any reason to use Application.Run. You can just use
the macro's name:

If UCase(Target.Cells(1).Value) = "Y" Then yourmacro

Cells(1) just in case the user does a Ctrl-Enter with multiple cells
selected. The UCase for case insensitivity.




--
Jim
"Carim" wrote in message
oups.com...
| Hi,
|
| Pretty simple with an event macro ...
|
| Private Sub Worksheet_Change(ByVal Target As Range)
| If Target.Value = "Y" Then
| Application.Run ("yourmacro")
| End If
| End Sub
|
| HTH
| Carim
|




All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com