빈칸끌어올리기VBA
빈칸 끌올
Sub FillBlankCells()
Dim rng As Range
Dim cell As Range
'선택영역
Set rng = Selection
'각 셀에 대한 루프 실행
For Each cell In rng
'빈셀인 경우
If cell.Value = "" Then
'그 아래 값이 있는 경우
If cell.Offset(1).Value <> "" Then
'그 아래 값을 현재 셀에 복사
cell.Value = cell.Offset(1).Value
'그 아래 값을 지움
cell.Offset(1).ClearContents
End If
End If
Next cell
End Sub
빈칸 왼쪽으로 당기기
Sub FillBlankCellsLeft()
Dim rng As Range
Dim cell As Range
'선택영역
Set rng = Selection
'각 셀에 대한 루프 실행
For Each cell In rng
'빈셀인 경우
If cell.Value = "" Then
'그 아래 값이 있는 경우
If cell.Offset(0,1).Value <> "" Then
'그 아래 값을 현재 셀에 복사
cell.Value = cell.Offset(0,1).Value
'그 아래 값을 지움
cell.Offset(0,1).ClearContents
End If
End If
Next cell
End Sub