View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro to remove space at front and end of a cell

There are two TRIM functions. In the worksheet TRIM removes leading and
trailing spaces. It also removes "extra" internal spaces.

In VBA, TRIM leaves the "internal" spaces alone. If you want to do the
automatic worksheet-style TRIM, then select the cells and run:

Sub dural()
For Each r In Selection
a = r.Address
r.Value = Evaluate("Trim(" & a & ")")
Next
End Sub

This will convert the values in-place
--
Gary''s Student - gsnu200770


"yhoy" wrote:

Similar to the TRIM() function but I would like to find a more automated way..

Thanks!