Press Alt F11 to run a script as a macro. This website offers some insight that may be helpful. 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.
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
. The last for..next
loop clears any remaining visible previous data.
All you need to do is:
Now all your empty cells should be selected
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.