Re: Delete Duplicate Rows depend on creteria on Col A and Col B
I need to paste new data 3 times @ least a day for each shift. ( imprtant thing is to see data SIDE BY SIDE)
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
I need to paste new data 3 times @ least a day for each shift. ( imprtant thing is to see data SIDE BY SIDE)
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
Then what's wrong?
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
Jindon - sorry to be a pain, This exactly what happen every time I paste new data (Check row 124 pl)
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
Change to
Sub test()
Dim a, i As Long, ub As Long, dic As Object, w, txt As String, x As Range
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
a = Sheets("dept hours").Cells(1).CurrentRegion.Value
ReDim Preserve a(1 To UBound(a, 1), 1 To UBound(a, 2) + 1)
For i = 1 To UBound(a, 1)
txt = Trim$(a(i, 1))
If Not dic.exists(txt) Then
dic(txt) = VBA.Array(a(i, 1), a(i, 2))
Else
w = dic(txt): w(1) = w(1) + a(i, 2): dic(txt) = w
End If
Next
With Sheets("time clock").Cells(1).CurrentRegion
.Parent.Cells.Font.ColorIndex = xlAutomatic
.Parent.Cells.Font.Bold = False
.Columns(.Columns.Count + 1).Resize(, .Columns.Count + 3).ClearContents
ub = .Rows.Count + 1
a = .Resize(.Rows.Count + dic.Count, .Columns.Count + 3).Value
For i = 1 To UBound(a, 1)
txt = Trim$(Replace(a(i, 1), ",", ""))
If dic.exists(txt) Then
a(i, UBound(a, 2) - 1) = dic(txt)(0)
a(i, UBound(a, 2)) = dic(txt)(1)
dic.Remove txt
If a(i, 2) <> a(i, UBound(a, 2)) Then
If x Is Nothing Then
Set x = Union(.Rows(i), .Rows(i).Offset(, 3))
Else
Set x = Union(x, Union(.Rows(i), .Rows(i).Offset(, 3)))
End If
End If
End If
Next
For i = 0 To dic.Count - 1
a(ub + i, UBound(a, 2) - 1) = dic.items()(i)(0)
a(ub + i, UBound(a, 2)) = dic.items()(i)(1)
Next
With .Resize(UBound(a, 1), UBound(a, 2))
.Parent.AutoFilterMode = False
.Value = a
If Not x Is Nothing Then x.Font.Color = vbRed: x.Font.Bold = True
.AutoFilter
.Parent.AutoFilter.Sort.SortFields.Clear
.Parent.AutoFilter.Sort.SortFields.Add(.Columns(1), _
xlSortOnFontColor, 1).SortOnValue.Color = RGB(255, 0, 0)
With .Parent.AutoFilter.Sort
.Header = xlYes
.Apply
End With
.AutoFilter
End With
.Parent.Cells.Columns.AutoFit
End With
End Sub
Display More
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
It worked once then on repeat same thing happen. I start a new workbook and try again tomorrow. enough for me today. thanks Jindon
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
Jindon- Looks like when I paste new data "space in between and in front of last name and first name creating issues. Would you wite a few lines of code to trim the space and commas make as one string please in s sepatate sub - Example Smith, John should be SmithJohn- All the names are in column A on bothe sheets.
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
You know the problem?
You should upload the data with all the possible combination/pattern of Col.A to be matched.
I will only write a code from what you upload, not by guess.
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
I have more than 200 line per shift-Thanks
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
C2:
=substitute(substitute(a2,",","")," ","")
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
Thank you for the contribution
Re: Delete Duplicate Rows depend on creteria on Col A and Col B
jindon
a(i, UBound(a, 3)) = dic(txt)(2) trying to modify your code to copy from column 3 values of Dept Hours to match entries of Time Clock - but no luck
Don’t have an account yet? Register yourself now and be a part of our community!