cell entry change to start a macro

Rob Mann

Board Regular
Joined
Jan 10, 2011
Messages
63
please can someone help.
in cell A1 i have a drop down list with 4 peoples names in. when someone picks a name (cell changes from blank, to a name) i want to run a macro. how do i do it. ppppplllllleeeeeeaaaaassssssseeeeee help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this: right click the sheet tab, select View Code and paste in

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then Call MyMacro
End Sub

Change MyMacro to the name of your macro.
 
Upvote 0
that almost works perfectly. thank you.
is there a way that it doesnt run the macro when "A1" entry is deleted. (when there is a name in the cell, and that job is complete we need to delete the contents of that cell but without the macro being called)
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" And Target.Value <> "" Then Call MyMacro
End Sub
 
Upvote 0
thank you, that works just as i wanted it to. just one last thing, iam using a macro that i've written to send out several emails at once. I want to populate the entry of a certain cell reference in the email. The code below shows the code i am using.

Msg = Msg & "A new entry has been added to the complaint spreadsheet, the new job number is " & Cells(r, 2) & "please read the comms and action immediately" & vbCrLf & vbCrLf

i know the (r, 2) refers to column B.
A=1 B=2 C=3 etc.
If i wanted to refer to cell "B3" instead of all the column B entries, how would i modify my current code?

Thank You
 
Upvote 0
Try

Code:
Msg = Msg & "A new entry has been added to the complaint spreadsheet, the new job number is " & Range("B3").Value & "please read the comms and action immediately" & vbCrLf & vbCrLf
 
Upvote 0
thats perfect!!! thank you.

my cell reference "M3" has a drop down box and the options are "yes" and "no". I would like before, to call the SendEmail macro if the entry changes to "Yes" but no "no" and blank. please could you help?
 
Upvote 0
Assuming that this is an additional condition try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" And Target.Value <> "" Then
    Call MyMacro
ElseIf Target.Address(False, False) = "M3" And LCase(Target.Value) = "yes" Then
    Call MyMacro
End If
End Sub
 
Upvote 0
Good Morning.
the code below works great.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" And Target.Value <> "" Then
Call MyMacro
ElseIf Target.Address(False, False) = "M3" And LCase(Target.Value) = "yes" Then
Call MyMacro
End If
End Sub


i have now developed my spread sheet and i want it to call my "email" macro if cell "b3","b4","b5" through to "b53" changes. any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top