ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing unwanted space at end of text cell (https://www.excelbanter.com/excel-programming/359397-removing-unwanted-space-end-text-cell.html)

Alastair79

Removing unwanted space at end of text cell
 
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.

AA2e72E

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.


Don Guillett

Removing unwanted space at end of text cell
 
have a look in help index for TRIM
To trim intervening spaces you may need
application.trim
see excel help

--
Don Guillett
SalesAid Software

"Alastair79" wrote in message
...
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.





All times are GMT +1. The time now is 06:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com