段を挙げてそろえるマクロコード

段を挙げてそろえるマクロコード

 

Sub ex()
Dim i As Long
Dim j As Long
Application.ScreenUpdating = False
If Cells(3, 3) <> "" Then Exit Sub
For i = 3 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(i, 1) <> "" Then
For j = 3 To 4
Cells(i, j) = Cells(i, j).End(xlDown)
Cells(i + 1, j).End(xlDown).Clear
Next j
End If
Next i
Application.ScreenUpdating = True
End Sub