Created
November 29, 2018 09:03
-
-
Save c0mpiler/d84b850be37b354fae2f270d807b3c9d to your computer and use it in GitHub Desktop.
assign the same serial no, for duplicate transaction rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub MarkDuplicates() | |
' Activate the Master Sheet | |
Sheets("master").Activate | |
' Count the number of non-empty rows in the master sheet | |
RowCount = Worksheets("master").Cells(Rows.Count, 1).End(xlUp).Row | |
ColCount = Worksheets("master").Cells(1, Columns.Count).End(xlToLeft).Column | |
dealAmtCol = 3 | |
firstRow = 1 | |
lastRow = RowCount | |
lastCol = ColCount | |
idx = 1 | |
For J = firstRow To lastRow | |
If Range(Cells(J, 1), Cells(J, lastCol)).Interior.Color <> 255 Then | |
For i = J + 1 To lastRow + 1 | |
If Cells(i, dealAmtCol) = Cells(J, dealAmtCol) Then | |
If Range(Cells(J, 1), Cells(J, lastCol)).Interior.Color <> 255 Then | |
Cells(J, 1).Value = idx | |
Range(Cells(J, 1), Cells(J, lastCol)).Interior.Color = 255 | |
Cells(i, 1).Value = idx | |
Range(Cells(i, 1), Cells(i, lastCol)).Interior.Color = 255 | |
Else | |
Cells(i, 1).Value = Cells(J, 1).Value | |
Range(Cells(i, 1), Cells(i, lastCol)).Interior.Color = 255 | |
End If | |
Else | |
If Range(Cells(J, 1), Cells(J, lastCol)).Interior.Color <> 255 Then | |
Cells(J, 1).Value = idx | |
Range(Cells(J, 1), Cells(J, lastCol)).Interior.Color = 255 | |
End If | |
End If | |
Next | |
idx = idx + 1 | |
End If | |
Next | |
For Each cell In Range(Cells(firstRow, 1), Cells(RowCount, ColCount)) | |
cell.Interior.Color = xlNone | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment