2015-01-15 193 views
0

我想知道是否有任何可用的公式或方法來執行此操作,而不是手動拖動單元格。對齊數據單元格值公式

我的數據是這樣的:enter image description here enter image description here

我應該怎麼得到的是這樣的上方。

有什麼可用的方法嗎?而不是一個一個地拖動單元格?我有這樣的大量數據。會爲任何解決方案感到高興。非常感謝!

+0

這是什麼? Excel中?如果是的話,你可以用VBA來做。 –

回答

0

你可以嘗試下面的代碼,它刪除空的單元格。 (只要您將搜索範圍更改爲所需)

Sub Del_Empty_cells() 
    Dim cell, del, searchRng As Range 
    Set searchRng = Range("A1:B10") 
    Set del = Nothing 
    For Each cell In searchRng.Cells 
     If cell = 0 Or cell = "" Then 
      If del Is Nothing Then 
       Set del = cell 
      Else 
       Set del = Application.Union(del, cell) 
      End If 
     End If 
    Next cell 
    If Not del Is Nothing Then del.Delete 
End Sub