You are on page 1of 2

chnvrhc.fur@landmarkgroup.

in - pan card cancel cheque leaf

Dim i, j, k, k1, k2, k3, k4 As Long


Dim p1(30), p2(30), p3(30), p4(30) As Variant
Dim str, str1, str2, str3, str4, str5 As String
Dim p(3000), q(3000), arr1(100, 100), arr2(2000, 100) As Variant
Dim ws As Worksheet

Set ws = Sheets("Reference")

For k = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row


q(k) = ws.Cells(k, "A")
Next

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

If m > 1 And str1 <> "" Then


Sheets("Temp").Cells(Sheets("Temp").Cells(Rows.Count, 5).End(xlUp).Row + 1, 5) =
str1
Sheets("Temp").Cells(Sheets("Temp").Cells(Rows.Count, 6).End(xlUp).Row + 1, 6) = m
End If

Next
Next

You might also like