[英]How to remove empty cells in excel?
Press Alt F11 to run a script as a macro.按 Alt F11 将脚本作为宏运行。 This website offers some insight that may be helpful.该网站提供了一些可能有用的见解。 https://www.excel-easy.com/vba/examples/delete-blank-cells.html https://www.excel-easy.com/vba/examples/delete-blank-cells.html
I hope this helps.我希望这有帮助。
This code is essentially the same as @Tony's, but it doesn't use any extra cells.此代码与@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
There is no chance of losing data, as there are blanks in the original, so that counter
is always less than or equal to i
.没有丢失数据的机会,因为原始文件中有空格,所以counter
总是小于或等于i
。 The last for..next
loop clears any remaining visible previous data.最后一个for..next
循环清除任何剩余的可见先前数据。
All you need to do is:您需要做的就是:
Now all your empty cells should be selected现在应该选择所有空单元格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.