Column D, Row 8 - 13 = list of yes, no, and N/A
Cell J8 = 3 seperate judgments: Pass, Fail, and one or more items needs resolved.
My question is how do I repeat the code in the same sheet for another list of yes, no, and N/A
Private Sub Worksheet_Change(ByVal Target As Range)
'********************************************************
' Update the Range Below to "Look for updates", in those
' cells. The Check will be run each time a cell in that
' range is updated.
'********************************************************
If Not Intersect(Target, Range("D8:D13")) Is Nothing Then
Call DetermineStatus
End If
End Sub
Sub DetermineStatus()
Dim rng As Range
Dim cell As Range
Dim OutputCell As Range
Dim Pass As Boolean
Dim Fail As Boolean
Dim Progress As Boolean
'*********************************************
' Set the range to Look for Yes and No here:
Set rng = Range("D8:D13")
'***************^^^^^^^************************
'**********************************************
' Set the cell to output the Status here:
Set OutputCell = Range("j8")
'**********************^^^^^*******************
Pass = False
Fail = False
Progress = False
For Each cell In rng
If cell.Value = "Yes" Or cell.Value = "yes" Then
If Fail Then
Progress = True
End If
Pass = True
End If
If cell.Value = "No" Or cell.Value = "no" Then
If Pass Then
Progress = True
End If
Fail = True
End If
Next cell
If Progress Then
'Set the output text for mixed Yes and No answers here:
OutputCell.Value = "One or more items still need attention"
ElseIf Pass Then
'Set the output text for a all Yes here:
OutputCell.Value = "Pass"
ElseIf Fail Then
'Set the output text for all No here:
OutputCell.Value = "Fail"
End If
End Sub
Bookmarks