选择某个区域,ctrl+G 定位空值,然后选择删除,下方单元格上移
我也不知道怎么弄,我等着看答案
Sub dataEntry()
Dim i As Integer, j As Integer, z As Integer, h As Integer, EndRow As Integer
Dim arr() As Integer
Dim EptCell2 As Integer, EptCell3 As Integer
'ReDim arr(0 To 0)
j = 0
EndRow = Application.WorksheetFunction.Max(Range("A65536").End(xlUp).Row, Range("B65536").End(xlUp).Row, Range("C65536").End(xlUp).Row)
For i = 1 To EndRow
If Cells(i, 1) <> "" Then
ReDim Preserve arr(j)
arr(j) = i
j = j + 1
End If
Next
ReDim Preserve arr(j)
arr(j) = EndRow + 1
For h = LBound(arr) To UBound(arr) - 1
For z = arr(h) To arr(h + 1) - 1
EptCell2 = FindEptCell(arr(h), arr(h + 1), 2)
If Cells(z, 2) <> "" And z > EptCell2 Then
Cells(EptCell2, 2) = Cells(z, 2)
Cells(z, 2) = ""
End If
EptCell3 = FindEptCell(arr(h), arr(h + 1), 3)
If Cells(z, 3) <> "" And z > EptCell3 Then
Cells(EptCell3, 3) = Cells(z, 3)
Cells(z, 3) = ""
End If
Next z
Next h
End Sub
Function FindEptCell(StartCell As Integer, EndCell As Integer, Col As Integer) As Integer
Dim i As Integer
For i = StartCell To EndCell
If Cells(i, Col) = "" Then
FindEptCell = i
Exit Function
End If
Next
End Function