Professional Documents
Culture Documents
Refund
Refund
Set ws = Sheets("Reference")
ActiveWorkbook.Save
For j = 1 To 4
ActiveWorkbook.Save
For i = 1 To Sheets("List").Cells(Rows.Count, j).End(xlUp).Row
str = Sheets("List").Cells(i, j)
For k = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row
If InStr(q(k), str) <> 0 Then
Sheets("Temp").Cells(Sheets("Temp").Cells(Rows.Count, j).End(xlUp).Row + 1, j) =
q(k)
End If
Next
Next
Next
Sheets("Temp").Select
For j = 1 To 3
For i = 2 To Sheets("Temp").Cells(Rows.Count, j).End(xlUp).Row
str1 = Sheets("Temp").Cells(i, j)
m = 0
If j + 1 <= 4 Then
For k = 2 To Sheets("Temp").Cells(Rows.Count, j + 1).End(xlUp).Row
str2 = Sheets("Temp").Cells(k, j + 1)
If str1 = str2 Then
m = m + 1
Sheets("Temp").Cells(k, j + 1) = ""
'MsgBox "j = " & j & vbNewLine & "String1 = " & str1 & vbNewLine & "String2 = " &
str2 & vbNewLine & "m = " & m
End If
Next
End If
If j + 2 <= 4 Then
For k = 2 To Sheets("Temp").Cells(Rows.Count, j + 2).End(xlUp).Row
str3 = Sheets("Temp").Cells(k, j + 2)
If str1 = str3 Then
m = m + 1
Sheets("Temp").Cells(k, j + 2) = ""
'MsgBox "j = " & j & vbNewLine & "String1 = " & str1 & vbNewLine & "String2 = " &
str2 & vbNewLine & "m = " & m
End If
Next
End If
If j + 3 <= 4 Then
For k = 2 To Sheets("Temp").Cells(Rows.Count, j + 3).End(xlUp).Row
str4 = Sheets("Temp").Cells(k, j + 3)
If str1 = str4 Then
m = m + 1
Sheets("Temp").Cells(k, j + 3) = ""
'MsgBox "j = " & j & vbNewLine & "String1 = " & str1 & vbNewLine & "String2 = " &
str2 & vbNewLine & "m = " & m
End If
Next
End If
Next
Next