Clearing cells that only contain spaces

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all!

Can anyone tell me how to write code to remove any number of spaces from cells that ONLY contain spaces?

Thank you!

Rodrigo
 
Dim rng as Range, cell as Range
On Error Resume Next
set rng = ActiveSheet.UsedRange.SpecialCells(xlconstants,xlTextValues)
On Error goto 0
for each cell in rng
if len(trim(cell.Value)) = 0 then
cell.Clearcontents
end if
Next

--
Regards,
Tom Ogilvy


Rodrigo Ayres said:
Hi all!

Can anyone tell me how to write code to remove any number of spaces from
cells that ONLY contain spaces?
 
Back
Top