macro

  • Thread starter Thread starter china
  • Start date Start date
C

china

Please help!

Anyone who can give me a macro program that will trim the
entire worksheet.
I want to have a two way of trimming
first is that -- no space before the data in a cell
second there should only one spacing.

Thanks
 
china

Sub TRIM_EXTRA_SPACES()
Dim Cell As Range
For Each Cell In Selection
If (Not IsEmpty(Cell)) And _
Not IsNumeric(Cell.Value) And _
InStr(Cell.Formula, "=") = 0 _
Then Cell.Value = Application.Trim(Cell.Value)
Next
End Sub

Gord Dibben Excel MVP
 

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