Да, вы можете сделать это, используя такой код. Он перемещается по одной строке за раз.
Sub Macro1()
' We don't know how long the file is. If we find more than 4 consequent
' empty cells in column A, we should stop looping
Dim EmptyCellCount As Integer
' Row number to start from
Dim MyRow As Integer
EmptyCellCount = 0
MyRow = 1
Do While EmptyCellCount < 5
' select A1 and check if there's any content in it
Range("A" & MyRow).Select
If Len(Trim(Range("A" & MyRow).Text)) > 0 Then
' select content from the next line and put in the current line
Range("C" & MyRow + 1 & ":Q" & MyRow + 1).Select
Selection.Cut
Range("C" & MyRow).Select
ActiveSheet.Paste
' switch to the next row and reset empty cell count
MyRow = MyRow + 1
EmptyCellCount = 0
Else
' switch to the next row and increment empty cell count
MyRow = MyRow + 1
EmptyCellCount = EmptyCellCount + 1
End If
Loop
End Sub
Этот перемещает весь блок на одну строку вверх
Sub Macro2()
Dim EmptyCellCount As Integer
Dim MyRow As Integer
MyRow = 1
' Find the cell where the last A cell is filled, approximately
Do While EmptyCellCount < 3
If Len(Trim(Range("A" & MyRow).Text)) > 0 Then
EmptyCellCount = 0
Else
EmptyCellCount = EmptyCellCount + 1
End If
MyRow = MyRow + 1
Loop
' Move the entire block up one row
Range("C2:Q" & MyRow).Select
Selection.Cut
Range("C1").Select
ActiveSheet.Paste
End Sub