|
Sub 剔除空单元格后重排数据()
Dim rng As Range, arr() As Variant
Dim i As Integer, m As Integer, n As Integer
Set rng = Range("a1:f10")
n = Application.WorksheetFunction.CountA(rng)
ReDim arr(1 To n)
For i = 1 To rng.Cells.Count
If Len(rng.Cells(i)) > 0 Then
m = m + 1
arr(m) = rng(i)
End If
Next i
rng.ClearContents
For i = 1 To UBound(arr)
rng(i) = arr(i)
Next i
Set rng = Nothing
End Sub
|
|