-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVLookUp_DeleteDuplicates
109 lines (98 loc) · 3.24 KB
/
VLookUp_DeleteDuplicates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Public bool As Boolean
Public Clicks As Integer
Public ClientFolderName As Variant
Public Year As Variant
Sub EndofTable()
Dim RowEnd As Integer
Dim NumberID As Integer
NumberID = 1
For EndTableRow = 12 To 20000
'Debug.Print EndTableRow
If IsEmpty(Cells(EndTableRow, 1)) Then
Exit For
ElseIf Not IsEmpty(Cells(EndTableRow, 1)) And IsEmpty(Cells(EndTableRow + 1, 1)) Then
RowEnd = EndTableRow
'Debug.Print RowEnd
End If
Next EndTableRow
'Copy and pasting whole table
Range("A12").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy Range("I12")
Range("I12").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
'removing duplicates depending how many Identifier are available
If Not IsEmpty(Cells(13, 3)) Then
With Selection
.RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
End With
ElseIf Not IsEmpty(Cells(13, 2)) Then
With Selection
.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
End With
Else
With Selection
.RemoveDuplicates Columns:=Array(1), Header:=xlYes
End With
End If
If Not IsEmpty(Cells(13, 3)) Then
Range("I13:K13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
ElseIf Not IsEmpty(Cells(13, 2)) Then
Range("I13:J13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Else
Range("I13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End If
'adding Claimant with incremented number to each cell
For ClaimID = 13 To 15000
If Not IsEmpty(Cells(ClaimID, 9)) Then
Cells(ClaimID, 13) = "Claimant " & NumberID
NumberID = NumberID + 1
Else
Exit For
End If
Next ClaimID
End Sub