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
 
First change A1 to =TODAY()

Then in B2, copied down

=IF(A2=A$1,"Yes","")
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
thank you.

ive just created a macro, do you think it will work.

most of the macro ive used in another workbook but on this one i need excel to close after running the macro.

Sub WORKBOOK_OPEN()
Sheets("sheet1").Visible = True
Sheets("sheet1").Select
If Time <= TimeValue("05:00 am") Then
Call SendEMail3
End If
Application.Wait (Now + TimeValue("0:05:00"))
Application.ActiveWorkbook.Close
End Sub
 
Upvote 0
That should work. If you actually want Excel to close you will need the Application.Quit line

Code:
Sub WORKBOOK_OPEN()
Sheets("sheet1").Visible = True
Sheets("sheet1").Select
If Time <= TimeValue("05:00 am") Then
    Call SendEMail3
End If
Application.Wait (Now + TimeValue("0:05:00"))
ActiveWorkbook.Close savechanges:=True
Application.Quit
End Sub
 
Upvote 0
Try like this

Code:
Private Sub CommandButton1_Click()
Dim pw As String
pw = InputBox("Enter password")
If pw <> "Rob" Then Exit Sub
'
'rest of code here
'
End Sub
 
Upvote 0
good morning

If I wanted to call "SendEmail4" if any of cell range "W2:W52" changed to "YES" how would I add it into the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G3:G52")) Is Nothing And Target.Value <> "" Then
Call SendEMail1
ElseIf Not Intersect(Target, Range("M3:M52")) Is Nothing And UCase(Target.Value) = "YES" Then
Call SendEMail2
End If
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G3:G52")) Is Nothing And Target.Value <> "" Then
    Call SendEMail1
ElseIf Not Intersect(Target, Range("M3:M52")) Is Nothing And UCase(Target.Value) = "YES" Then
    Call SendEMail2
ElseIf Not Intersect(Target, Range("W3:W52")) Is Nothing And UCase(Target.Value) = "YES" Then
    Call SendEMail4
End If
End Sub
 
Upvote 0
in the code below is there a way of when "M3" is changed to "YES" that it prints the defined print area of "sheet2". And when "M4" is changed to "YES" it prints the defined print area of "sheet3" and so on and so on up until "M52"

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G3:G52")) Is Nothing And Target.Value <> "" Then
Call SendEMail1
ElseIf Not Intersect(Target, Range("M3:M52")) Is Nothing And UCase(Target.Value) = "YES" Then
Call SendEMail2
ElseIf Not Intersect(Target, Range("W3:W52")) Is Nothing And UCase(Target.Value) = "YES" Then
Call SendEMail4
End If
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G3:G52")) Is Nothing And Target.Value <> "" Then
    Call SendEMail1
ElseIf Not Intersect(Target, Range("M3:M52")) Is Nothing And UCase(Target.Value) = "YES" Then
    Call SendEMail2
    Sheets("Sheet" & Target.Row - 1).PrintOut
ElseIf Not Intersect(Target, Range("W3:W52")) Is Nothing And UCase(Target.Value) = "YES" Then
    Call SendEMail4
End If
End Sub
 
Upvote 0
i guess the ("Sheet" & Target.Row -1). PrintOut mean look at the row number then subtract 1 and go to that sheet?

row 3 -1 = sheet 2.

i'm asking because i forgot that i have hidden sheet 2. so i need row 3 to print "sheet3"

how should I change the code?

i deleted the "- 1" part but i got an error.
 
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,960
Members
449,057
Latest member
FreeCricketId

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