If Err.Number = 0 Then
datas(1, xx) = .Cells(0, x)
datas(2, xx) = .Cells(y, x)
Else
If .Cells(0, x) = datas(0, 0) Then
If .Cells(0, 5) = datas(0, 7) Then
datas(1, 7) = .Cells(y, 5)
Else
datas(1, 8) = .Cells(y, 6)
End If
Else
datas(1, 5) = .Cells(y, 5)
End If
End If
If Left(.Cells(0, x), 6) = "System" Then
datas(2, xx) = "YES"
If tbls > 1 Then datas(2, xx) = .Cells(y, 3)
End If
Next x
With Sheets("Sheet2").Range("LadyDee")
y_max = .Rows.Count + 1
If tbls = 1 And y = 1 Then y_max = y_max - 1
ADD_NEW = True
For yy = 1 To y_max
If .Cells(yy, 1) = datas(2, 1) And .Cells(yy, 2) = datas(2, 2) And _
.Cells(yy, 3) = datas(2, 3) And .Cells(yy, 4) = datas(2, 4) Then
If tbls < 3 Or (tbls = 3 And .Cells(yy, 8) = Empty) Then
For x = 1 To 8
If datas(2, x) <> Empty Then .Cells(yy, x) = datas(2, x)
Next x
ADD_NEW = False
yy = y_max + 1
End If
End If
Next yy
If ADD_NEW Then
For x = 1 To 8
If datas(2, x) <> Empty Then _
.Cells(y_max, x) = datas(2, x)
Next x
End If
End With
For yy = 1 To 2
For xx = 0 To 8
datas(yy, xx) = Empty
Next xx
Next yy
Next y
End With