Hi,
I have made necessary changes but getting error 91.
Something is wrong in my coding. Sorry for not understanding your suggestion correctly.
Please do the necessary amendments in the code below to achieve the target.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
' 16 = P, 30 = AD
If Target.Column = 16 Or Target.Column = 30 Then
Application.EnableEvents = False
If Not Intersect(Target, Range("P:P")) Is Nothing Then
For Each cell In Intersect(Target, Range("P:P"))
If Target.Row < 9 Then Exit Sub
If Target.Column <> 16 Then Exit Sub
If cell.Value = "" Then
Cells(cell.Row, "W").Value = ""
Else
Cells(cell.Row, "W").Formula = _
"=IF(RC[-7]="""","""",IF(RC[-20]=""Duplicate"",""Duplicate"",IF(AND(RC[-7]=""-"",RC[-6]=""-""),""-"",IF(COUNT(RC[-7]:RC[-6])=1,""Sanctioned"",""Expired""))))"
'.Value = .Value
End If
Columns.AutoFit
Next cell
End If
'Remark 3
If Not Intersect(Target, Range("P:P")) Is Nothing Then
For Each cell In Intersect(Target, Range("P:P"))
If Target.Row < 9 Then Exit Sub
If Target.Column <> 16 Then Exit Sub
If cell.Value = "" Then
Cells(cell.Row, "AG").Value = ""
Else
Cells(cell.Row, "AG").Formula = _
"=IF(RC[-10]=""Sanctioned"",""Send mail"",IF(RC[-10]=""Expired"",""Closed"",IF(RC[-10]=""-"",""Closed"",IF(RC[-10]=""Duplicate"",""Closed"",""""))))"
'.Value = .Value
End If
Columns.AutoFit
Next cell
End If
End If
'Remark2
If Not Intersect(Target, Range("AD:AD")) Is Nothing Then
For Each cell In Intersect(Target, Range("AD:AD"))
If Target.Row < 9 Then Exit Sub
If Target.Column <> 30 Then Exit Sub
If cell.Value = "" Then
Cells(cell.Row, "AF").Value = ""
Else
Cells(cell.Row, "AF").Formula = _
"=IF(RC[-2]="""","""",IF(AND(RC[-2]=""-"",RC[-1]=""-""),""-"",IF(COUNT(RC[-2]:RC[-1])=1,""Send mail"",""Expired"")))"
'.Value = .Value
End If
Columns.AutoFit
Next cell
End If
Application.EnableEvents = True
End Sub
Thank you.
Bookmarks