Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
If Target.Value = "no" Then
Cells(Target.Row, 1).Copy Worksheets("HAM NO").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
On Error Resume Next
Set rcell = Worksheets("HAM YES").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
Set rcell = Worksheets("HAM UNKNOWN").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
ElseIf Target.Value = "yes" Then
Cells(Target.Row, 1).Copy Worksheets("HAM YES").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
On Error Resume Next
Set rcell = Worksheets("HAM NO").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
Set rcell = Worksheets("HAM UNKNOWN").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
ElseIf Target.Value = "" Then
Cells(Target.Row, 1).Copy Worksheets("HAM UNKNOWN").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
On Error Resume Next
Set rcell = Worksheets("HAM YES").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
Set rcell = Worksheets("HAM NO").Cells.Find(What:=Cells(Target.Row, 1).Value, After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rcell.Value = ""
End If
ElseIf Target.Column = 3 Then
'REpeat above code for PRA
ElseIf Target.Column = 4 Then
'REpeat above code for UP
ElseIf Target.Column = 5 Then
'Repeat above code for HAFA
End If
For i = 1 To Worksheets.Count
If Worksheets(i) <> "Master" Then
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Columns("A:A").RemoveDuplicates Columns:=1, Header:=xlNo
End If
Next i
End Sub
I have completed the code for HAM YES, NO & UNKNOWN. Just copy the same code for PRA, UP & HAFA and change the sheet names. Do let me know if you need help with it.
Bookmarks