Excel telling me my blank cells aren't blank
a simple way to select and clear these blank cells to make them blank:
- Press ctrl + a or pre-select your range
- Press ctrl + f
- Leave find what empty and select match entire cell contents.
- Hit find all
- Press ctrl + a to select all the empty cells found
- Close the find dialog
- Press backspace or delete
This worked for me:
- CTR-H to bring up the find and replace
- leave 'Find What' blank
- change 'Replace with' to a unique text, something that you are
positive won't be found in another cell (I used 'xx') - click 'Replace All'
- copy the unique text in step 3 to 'Find what'
- delete the unique text in 'Replace with'
- click 'Replace All'
A revelation: Some blank cells are not actually blank! As I will show cells can have spaces, newlines and true empty:
To find these cells quickly you can do a few things.
- The
=CODE(A1)
formula will return a #VALUE! if the cell is truly empty, otherwise a number will return. This number is the ASCII number used in=CHAR(32)
. - If you select the cell and click in the formula bar and use the cursor to select all.
Removing these:
If you only have a space in the cells these can be removed easily using:
- Press ctrl + h to open find and replace.
- Enter one space in the find what, leave replace with empty and ensure you have match entire cell contents is ticked in the options.
- Press replace all.
If you have newlines this is more difficult and requires VBA:
- Right click on the sheet tab > view code.
Then enter the following code. Remember the
Chr(10)
is a newline only replace this as required, e.g." " & Char(10)
is a space and a newline:Sub find_newlines() With Me.Cells Set c = .Find(Chr(10), LookIn:=xlValues, LookAt:=xlWhole) If Not c Is Nothing Then firstAddress = c.Address Do c.Value = "" Set c = .FindNext(c) If c Is Nothing Then Exit Do Loop While c.Address <> firstAddress End If End With End Sub
Now run your code pressing F5.
After file supplied: Select the range of interest for improved performance, then run the following:
Sub find_newlines()
With Selection
Set c = .Find("", LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = ""
Set c = .FindNext(c)
If c Is Nothing Then Exit Do
Loop While c.Address <> firstAddress
End If
End With
End Sub