vba 删除空值的单元格,上移数据

Sub aa()
    Dim arr As Variant
    Dim i As Integer
    Dim j As Integer
    Dim rng As Range
    Dim temp As Variant
    
    arr = Range("a1", [a65536].End(3)).Value
    j = 1
    For i = 1 To UBound(arr)
        If arr(i, 1) <> "" Then
          Worksheets("Sheet2").Cells(i, 1).Value = ""
          Worksheets("Sheet2").Cells(j, 1).Value = arr(i, 1)
          j = j + 1
        End If
    Next
    
End Sub

 

posted on 2016-04-14 16:00  shortail  阅读(1604)  评论(0编辑  收藏  举报