ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to run (https://www.excelbanter.com/excel-programming/278238-macro-run.html)

Stu[_24_]

Macro to run
 
~Is it possible to set up a macro to run if something is put in a
certain cell? (eg. B3 to run macro "All").

Thanks

Stu



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Stu[_25_]

Macro to run when something is in B3
 
Actually if a value changes in a certain cell

--
Stu



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Chip Pearson

Macro to run
 
Stu,

You can use the Change event of the worksheet. In the code module for the
appropriate worksheet, use the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" Then
If StrComp(Target.Text, "All", vbTextCompare) = 0 Then
' your code here
End If
End If
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Stu" wrote in message
...
~Is it possible to set up a macro to run if something is put in a
certain cell? (eg. B3 to run macro "All").

Thanks

Stu



------------------------------------------------
~~ Message posted from
http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Bob Phillips[_5_]

Macro to run
 
Stu,

You can trap a change to a cell using worksheet event code

Private Sub Worksheet_Change(ByVal Target As Range)

Application .EnableEvents = False
On Error GoTo ws_exit
If (Not Intersect(Target, Range("B3")) Is Nothing) Then
'add a call to your macro here
End If

ws_exit:
Application.EnableEvents = True
End Sub

To add this, right-click on the sheet name tab, select View Coide from the
menu, and paste the code in .

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stu" wrote in message
...
~Is it possible to set up a macro to run if something is put in a
certain cell? (eg. B3 to run macro "All").

Thanks

Stu



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:54 AM.

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