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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top