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"
[TABLE="class: cms_table_cms_table, width: 271"]
<tbody>[TR]
[TD="align: center"]Name[/TD]
[TD="align: center"]Email address[/TD]
[TD="align: center"]Condition1[/TD]
[TD="align: center"]Condition2[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]1@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]2@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]3@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed
[/TD]
[/TR]
</tbody>[/TABLE]
**Lets assume the colums are "N" for condition1 and column "S" for condition2 in the above case.**
I have written the code below but doesnt seem to work
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
LR = Range("S" & Rows.Count).End(xlUp).Row
'This assumes a Header Row in S1
If Not Intersect(Target, Range("S2:S" & LR)) Is Nothing Then
' If Target.Value = "Initiated" Then
Call Create_Mail_From_List1(Target)
' End If
End If
End If
End Sub
[TABLE="class: cms_table, width: 271"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
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"
[TABLE="class: cms_table_cms_table, width: 271"]
<tbody>[TR]
[TD="align: center"]Name[/TD]
[TD="align: center"]Email address[/TD]
[TD="align: center"]Condition1[/TD]
[TD="align: center"]Condition2[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]1@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]2@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed[/TD]
[/TR]
[TR]
[TD="align: center"]User1[/TD]
[TD="align: center"]3@c.com[/TD]
[TD="align: center"]Initiated[/TD]
[TD="align: center"]Completed
[/TD]
[/TR]
</tbody>[/TABLE]
**Lets assume the colums are "N" for condition1 and column "S" for condition2 in the above case.**
I have written the code below but doesnt seem to work
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
LR = Range("S" & Rows.Count).End(xlUp).Row
'This assumes a Header Row in S1
If Not Intersect(Target, Range("S2:S" & LR)) Is Nothing Then
' If Target.Value = "Initiated" Then
Call Create_Mail_From_List1(Target)
' End If
End If
End If
End Sub
[TABLE="class: cms_table, width: 271"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]