Hello,
I am a new in vba and now I want to search for duplicates in column a of all work sheets, sum the total working hours including duplicate date in column d and show sum value in other excel.
Can Someone help to me and now I found someone posted the following code on this board it was not complete code that i want.
Sub Test()
Dim Sh As Worksheet
Dim LastRow As Long
Dim Rng As Range
Set Sh = Worksheets(1)
Sh.Columns(5).Insert
LastRow = Sh.Range("A65536").End(xlUp).Row
With Sh.Range("A1:A" & LastRow).Offset(0, 4)
.FormulaR1C1 = "=IF(COUNTIF(R1C[-4]:RC[-4],RC[-4])>1,"""",SUMIF(R1C[-4]:R[" & LastRow & "]C[-4],RC[-4],R1C[-1]:R[" & LastRow & "]C[-1]))"
.Value = .Value
End With
Sh.Columns(4).Delete
Sh.Rows(1).Insert
Set Rng = Sh.Range("D1:D" & LastRow + 1)
With Rng
.AutoFilter Field:=1, Criteria1:="="
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
End Sub
*** Now i want to show result in other excel(from B14 of Sheett1 ) without delete duplicate data from the original excel. When showing sum value in the other excel, I want to split value number for decimal value. For example (if all sum value of working hours is 5.5 hour >> 5 hours and 30 minites or 5.0 hour >> 5 hours and 0 minites ) the value of decimal want to show by line break.
*want to show result like this .
[TABLE="class: outer_border, width: 600, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]~[/TD]
[TD]~[/TD]
[TD]~[/TD]
[TD]AI[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]~[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Employee name[/TD]
[TD]06/01[/TD]
[TD]06/02[/TD]
[TD]06/03[/TD]
[TD]~[/TD]
[TD]06/30[/TD]
[TD]06/31[/TD]
[TD]Total[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]David[/TD]
[TD]2 (hours)[/TD]
[TD][/TD]
[TD]2[/TD]
[TD][/TD]
[TD]2[/TD]
[TD][/TD]
[TD]7(hour)[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD][/TD]
[TD]30(minute)[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30(minute)[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]Jenifer[/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]Maikel[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]total[/TD]
[TD]13(hrs)[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]30(min)[/TD]
[/TR]
</tbody>[/TABLE]
*find sum duplicate working hours for all worksheets.(eg. sheet name is David)
[TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Total Hours[/TD]
[TD]21.0[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Date[/TD]
[TD] Major Item[/TD]
[TD]Small Item[/TD]
[TD]Working Hour[/TD]
[TD]Remarks[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]2018/6/1[/TD]
[TD] Major Item1[/TD]
[TD]Small Item1[/TD]
[TD]0.5[/TD]
[TD]remark1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2018/6/1[/TD]
[TD]Major Item2[/TD]
[TD]Small Item2[/TD]
[TD]2.0[/TD]
[TD]remark2[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD]2018/6/3[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 128"]
<tbody>[TR]
[TD] Major Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 127"]
<tbody>[TR]
[TD]Small Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD]2.5[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD]remark4[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD]2018/6/30[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 128"]
<tbody>[TR]
[TD] Major Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 127"]
<tbody>[TR]
[TD]Small Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD]2.5[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 145"]
<tbody>[TR]
[TD]remark4[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
I am a new in vba and now I want to search for duplicates in column a of all work sheets, sum the total working hours including duplicate date in column d and show sum value in other excel.
Can Someone help to me and now I found someone posted the following code on this board it was not complete code that i want.
Sub Test()
Dim Sh As Worksheet
Dim LastRow As Long
Dim Rng As Range
Set Sh = Worksheets(1)
Sh.Columns(5).Insert
LastRow = Sh.Range("A65536").End(xlUp).Row
With Sh.Range("A1:A" & LastRow).Offset(0, 4)
.FormulaR1C1 = "=IF(COUNTIF(R1C[-4]:RC[-4],RC[-4])>1,"""",SUMIF(R1C[-4]:R[" & LastRow & "]C[-4],RC[-4],R1C[-1]:R[" & LastRow & "]C[-1]))"
.Value = .Value
End With
Sh.Columns(4).Delete
Sh.Rows(1).Insert
Set Rng = Sh.Range("D1:D" & LastRow + 1)
With Rng
.AutoFilter Field:=1, Criteria1:="="
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
End Sub
*** Now i want to show result in other excel(from B14 of Sheett1 ) without delete duplicate data from the original excel. When showing sum value in the other excel, I want to split value number for decimal value. For example (if all sum value of working hours is 5.5 hour >> 5 hours and 30 minites or 5.0 hour >> 5 hours and 0 minites ) the value of decimal want to show by line break.
*want to show result like this .
[TABLE="class: outer_border, width: 600, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]~[/TD]
[TD]~[/TD]
[TD]~[/TD]
[TD]AI[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]~[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Employee name[/TD]
[TD]06/01[/TD]
[TD]06/02[/TD]
[TD]06/03[/TD]
[TD]~[/TD]
[TD]06/30[/TD]
[TD]06/31[/TD]
[TD]Total[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]David[/TD]
[TD]2 (hours)[/TD]
[TD][/TD]
[TD]2[/TD]
[TD][/TD]
[TD]2[/TD]
[TD][/TD]
[TD]7(hour)[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD][/TD]
[TD]30(minute)[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30(minute)[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]Jenifer[/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]Maikel[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[TD]30[/TD]
[TD][/TD]
[TD]30[/TD]
[TD][/TD]
[TD]00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]total[/TD]
[TD]13(hrs)[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]30(min)[/TD]
[/TR]
</tbody>[/TABLE]
*find sum duplicate working hours for all worksheets.(eg. sheet name is David)
[TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Total Hours[/TD]
[TD]21.0[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Date[/TD]
[TD] Major Item[/TD]
[TD]Small Item[/TD]
[TD]Working Hour[/TD]
[TD]Remarks[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]2018/6/1[/TD]
[TD] Major Item1[/TD]
[TD]Small Item1[/TD]
[TD]0.5[/TD]
[TD]remark1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2018/6/1[/TD]
[TD]Major Item2[/TD]
[TD]Small Item2[/TD]
[TD]2.0[/TD]
[TD]remark2[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD]2018/6/3[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 128"]
<tbody>[TR]
[TD] Major Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 127"]
<tbody>[TR]
[TD]Small Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD]2.5[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD]remark4[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD]2018/6/30[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 128"]
<tbody>[TR]
[TD] Major Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 127"]
<tbody>[TR]
[TD]Small Item4[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 130"]
<tbody>[TR]
[TD]2.5[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD][TABLE="width: 145"]
<tbody>[TR]
[TD]remark4[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]