We put information from all types of sources into our Excel workbooks, usually just by copying and pasting or by using another program to extract data from a database. In either case, sometimes this produces undesired results. Cells that may appear empty really aren’t, as they will often times contain spaces. Usually this isn’t a problem, but sometimes pivot tables or other features in Excel will read the space as a value, when it really should be read as 0.
Copy all of the code below. Paste it into your workbook’s Visual Basic editor, in a Module, or Microsoft Excel Object (This Workbook, Sheet1, Sheet2, etc.).
Need help? Use our nifty guide to help figure out how to install and use your macros.
'MACROS BY EXCELZOOM.COM
Dim rangeSheet As Range
Dim rangeText As Range
Set rangeText = Cells.SpecialCells( _
For Each rangeSheet In rangeText
If Trim(rangeSheet.Value) = "" Then
Set rangeText = Nothing
Set rangeSheet = Nothing