Hi mdmackillop
I am having a run time error "13" Type mismatch when I adjust the script based on the original file. When I debug it highlights
I am sure the data format is exactly the same with the sample test file. I really don't know what's causing to this problem
Sub test()
Dim sh As Worksheet
Dim Dic
Dim i
Dim x As String, y As Single
Dim k
Set Dic = CreateObject("Scripting.Dictionary")
For Each sh In Worksheets
With sh
If .Name <> "Master" Then
For i = 2 To LR(sh, 1)
x = .Cells(i, 3) & "-" & .Cells(i, 4) & "-" & .Cells(i, 5) & "-" & .Cells(i, 6) & "-" & .Cells(i, 7) & "-" & .Cells(i, 8) & "-" & .Cells(i, 9) & "-" & .Cells(i, 10)
y = .Cells(i, 11)
If Dic.exists(x) Then
Dic(x) = CStr(Dic(x) + y)
Else
Dic.Add x, CStr(y)
End If
Next i
End If
End With
Next sh
Set sh = Sheets("Master")
i = 1
For Each k In Dic.Keys
i = i + 1
Cells(i, 1) = Split(k, "-")(0)
Cells(i, 2) = Split(k, "-")(1)
Cells(i, 3) = Split(k, "-")(2)
Cells(i, 4) = Split(k, "-")(3)
Cells(i, 5) = Split(k, "-")(4)
Cells(i, 6) = Split(k, "-")(5)
Cells(i, 7) = Split(k, "-")(6)
Cells(i, 8) = Split(k, "-")(7)
Cells(i, 9) = Dic(k)
Next
Range("A2:G" & i).NumberFormat = "0000"
End Sub
Function LR(sh, col) As Long
LR = sh.Cells(Rows.Count, col).End(xlUp).Row
End Function