Two Cell Change Worksheet Macro - Private Sub Worksheet_Change(ByVal Target As Range)

Srivatsal

New Member
Joined
Dec 4, 2017
Messages
7
Hi,

Need help I am new pretty new to VBA, created a worksheet it is working for 1 condition but I tried a lot but unable to make it work for the second condition in the same worksheet.

Background: The first code pasted below calls the I need to below code to call a macro when the condition1 cell changes to "Initaited" similarly I want it to call second macro in general module when the condition1 cell changes to "Completed"

PLEASE HELP

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Range("N" & Rows.Count).End(xlUp).Row
'This assumes a Header Row in N1
If Not Intersect(Target, Range("N2:N" & LR)) Is Nothing Then
' If Target.Value = "Initiated" Then
Call Create_Mail_From_List(Target)
' End If
End If
End Sub

Name
Email address
Condition1
Condition2
User1
1@c.com
Initiated
Completed
User1
2@c.com
Initiated
Completed
User1
3@c.com
Initiated
Completed

<tbody>
</tbody>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Maybe this is what you want:
Modify to your needs. Or explain more.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Range("N" & Rows.Count).End(xlUp).Row
'This assumes a Header Row in N1
If Not Intersect(Target, Range("N2:N" & LR)) Is Nothing Then
If Target.Value = "Initiated" Then Call Bob
If Target.Value = "Completed" Then Call George
End If
End If
End Sub
 
Upvote 0
Maybe this is what you want:
Modify to your needs. Or explain more.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Range("N" & Rows.Count).End(xlUp).Row
'This assumes a Header Row in N1
If Not Intersect(Target, Range("N2:N" & LR)) Is Nothing Then
If Target.Value = "Initiated" Then Call Bob
If Target.Value = "Completed" Then Call George
End If
End If
End Sub

Tried it but does not work Unfortunatley... If anybody could help me on this please.
 
Upvote 0
NameEmail addressCondition1Condition2
User11@c.comInitiatedCompleted
User12@c.comInitiatedCompleted
User13@c.comInitiatedCompleted


<tbody>
</tbody>
Lets assume the colums are "N" for condition1 and column "S" for condition2 in the above case. Please help guys!!
 
Upvote 0
Try this:

Modify calling Macro name.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 14 Or Target.Column = 19 Then
If Target.Column = 14 And Target.Value = "Initiated" Then Call Bob
If Target.Column = 19 And Target.Value = "Completed" Then Call George
End If
End Sub
 
Upvote 0
Try this:

Modify calling Macro name.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 14 Or Target.Column = 19 Then
If Target.Column = 14 And Target.Value = "Initiated" Then Call Bob
If Target.Column = 19 And Target.Value = "Completed" Then Call George
End If
End Sub

This is also not working - Its giving a compile error on "Exit Sub" and highlighting yellow on the first line "Private Sub Worksheet_Change(ByVal Target As Range)"

[IMG]C:\Users\lakshmis\Desktop\Macro[/IMG]
 
Upvote 0
If I understand you correctly you want:

If you enter "Initiated" in column "N" you want to run a macro
If you enter "Completed" in column "S" you want to run a macro

So I have call Bob
Call George

I do not know the names of the Macros you want to run so you must change George and Bob to the Macro name you want to run

If this is not what you want then you need to explain more
 
Upvote 0

Forum statistics

Threads
1,212,933
Messages
6,110,752
Members
448,295
Latest member
Uzair Tahir Khan

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