|
Sub test()
Set d = CreateObject("scripting.dictionary")
Sheets(1).Select
Application.ScreenUpdating = False
For j = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
If Len(Cells(1, j)) > 0 Then d(j) = Cells(1, j)
Next j
For j = 2 To Sheets.Count
arr = Sheets(j).UsedRange
r = 0
For i = 1 To UBound(arr)
For k = 1 To UBound(arr, 2)
If d.exists(k) Then
If arr(i, k) <> d(k) Then
GoTo l1
End If
End If
Next k
r = r + 1
For k = 1 To UBound(arr, 2)
arr(r, k) = arr(i, k)
Next k
l1:
Next i
If r > 0 Then
Sheets(j).UsedRange.Offset(1).ClearContents
Sheets(j).[a1].Resize(r, UBound(arr, 2)) = arr
End If
Next
Application.ScreenUpdating = True
End Sub
|
|