I have coded this in one of my workbooks:
Now, I want to remove duplicates rows according to the base of E column. When I run macro using this VBA code, an output is coming. In that output, in E column I have seen some duplicates are also coming. But I only need one data among the duplicates. For exmaple, in my E column I have found "CMCDG31" comes 3 times, but I only need once, rest 2 should be deleted.
But there is one more thing, I should count only 7 letters from Right when removing duplicates from E column. For example: If there is CMCDG31, D_CMCDG31, I_CMCDG31 then all of these should be count as duplicates, as If I use Right(Cell,7), then output of all of these three cells are same, that is CMCDG31. So, I have to discard 2 rows and keep 1.
I need the vba code for removing these duplicates with entire row.
Thanks in Advance.
Code:
With wsA
dtD = .Range("D2") ' Date cell
End With
UBB = UBound(vRB, 1)
ReDim vRG(1 To 12, 1 To 1)
For lRC = 2 To UBB
If dtD - vRB(lRC, 3) > 0 And dtD - vRB(lRC, 7) = dtD And Len(Trim(vRB(lRC, 2))) And InStr(vRB(lRC, 2), "None") = 0 And InStr(vRB(lRC, 2), "NULL") = 0 And InStr(vRB(lRC, 2), "_COW") = 0 And InStr(vRB(lRC, 2), "D_") = 0 And InStr(vRB(lRC, 2), "D2_") = 0 And InStr(vRB(lRC, 2), "D3_") = 0 And InStr(vRB(lRC, 4), "ERC-3G-") = 0 And InStr(vRB(lRC, 4), "NSN-WCDMA") = 0 Then ' time difference > 0 hrs
UBG = UBound(vRG, 2) + 1
ReDim Preserve vRG(1 To 12, 1 To UBG)
' copy the values from input to output array
For lRB = 1 To 10
vRG(lRB + 1, UBG) = vRB(lRC, lRB)
Next lRB
' put date in correct format
vRG(3, UBG) = Format(vRG(3, UBG), "DD/MM/YYY HH:MM")
' check if Region in All Site
For lRI = 3 To UBI
If Right(vRB(lRC, 2), 7) = vRI(lRI, 1) Then ' same code
vRG(1, UBG) = vRI(lRI, 3) ' copy region to first column of vRC
Exit For
End If
Next lRI
vRG(12, UBG) = dtD - vRB(lRC, 3)
'vRG(12, UBG) = Format(vRG(12, UBG), "HH:MM")
End If
Next lRC
' copy headings
vRG(1, 1) = "Region"
For lRB = 1 To 10
vRG(lRB + 1, 1) = vRB(1, lRB)
Next lRB
With wsG.Range("C4")
.CurrentRegion.ClearContents
.Resize(UBound(vRG, 2), UBound(vRG, 1)).Value = Application.WorksheetFunction.Transpose(vRG)
End With
Now, I want to remove duplicates rows according to the base of E column. When I run macro using this VBA code, an output is coming. In that output, in E column I have seen some duplicates are also coming. But I only need one data among the duplicates. For exmaple, in my E column I have found "CMCDG31" comes 3 times, but I only need once, rest 2 should be deleted.
But there is one more thing, I should count only 7 letters from Right when removing duplicates from E column. For example: If there is CMCDG31, D_CMCDG31, I_CMCDG31 then all of these should be count as duplicates, as If I use Right(Cell,7), then output of all of these three cells are same, that is CMCDG31. So, I have to discard 2 rows and keep 1.
I need the vba code for removing these duplicates with entire row.
Thanks in Advance.