Sub test()
Set d = CreateObject("scripting.dictionary")
zr = Sheet1.[a1].End(xlDown).Row
zc = Sheet1.[a1].End(xlToRight).Column
arr = Sheet1.Range(Sheet1.Cells(1, 1), Sheet1.Cells(zr, zc))
For i = 3 To zr
For j = 2 To zc Step 2
If arr(i, j) <> "" And arr(i, j + 1) <> "" Then
d(arr(i, 1) & "|" & arr(2, j)) = Array(arr(i, j), arr(i, j + 1))
End If
Next
Next
ReDim crr(1 To 1 + d.Count, 1 To 4)
crr(1, 1) = "井号"
crr(1, 2) = "层系名"
crr(1, 3) = "MD"
crr(1, 4) = "TVD"
m = 1
For Each Key In d
m = m + 1
crr(m, 1) = Split(Key, "|")(0)
crr(m, 2) = Split(Key, "|")(1)
crr(m, 3) = d(Key)(0)
crr(m, 4) = d(Key)(1)
Next
Sheet2.[O1].Resize(UBound(crr), UBound(crr, 2)) = crr
End Sub
|