2015-01-15 194 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