[英]How to remove empty cells in excel?
按 Alt F11 將腳本作為宏運行。 該網站提供了一些可能有用的見解。 https://www.excel-easy.com/vba/examples/delete-blank-cells.html
我希望這有幫助。
此代碼與@Tony 的代碼基本相同,但它不使用任何額外的單元格。
Dim counter As Integer, i As Integer
counter = 1
For i = 1 To 10
If Cells(i, 1) <> "" Then
Cells(counter, 1) = Cells(i, 1)
counter = counter + 1
End If
Next i
For i = counter To 10
Cells(i, 1) = ""
Next i
沒有丟失數據的機會,因為原始文件中有空格,所以counter
總是小於或等於i
。 最后一個for..next
循環清除任何剩余的可見先前數據。
您需要做的就是:
現在應該選擇所有空單元格
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.