View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default Removing unwanted space at end of text cell

If you want to trim the cell values in situ, you need to do it with code:

e.g.
range("E4").Formula=trim(Range("E4").value)

trims (removes leading & trailing blanks) from the contents of E4.

For a given range, try:

Sub aa()
For Each ThisCell In Range("A1:B4") ' specify your rangel
ThisCell.Formula = Trim(ThisCell)
Next
End Sub

"Alastair79" wrote:

I have a Column of branch names but they all have a lot of spaces after the
name, is the anyway with VB that I can trim to just the branch name?

Thanks........ Alastair.