Stubby
Board Regular
- Joined
- Mar 5, 2002
- Messages
- 188
Hi All
I am struggling to use the Trim feature in VBA. I have a block of data that often has an extra space or two either at the beginning or end of the text. I have used the following code to try and resolve this but i cant get the result of the Trim to be placed back into the spreadsheet. Can anyone see where I am going wrong!!
Sub testing()
Range("a5").CurrentRegion.Select
For Each x In Selection
trimstring = Trim(x)
x = trimstring
Next
End Sub
Many thanks
I am struggling to use the Trim feature in VBA. I have a block of data that often has an extra space or two either at the beginning or end of the text. I have used the following code to try and resolve this but i cant get the result of the Trim to be placed back into the spreadsheet. Can anyone see where I am going wrong!!
Sub testing()
Range("a5").CurrentRegion.Select
For Each x In Selection
trimstring = Trim(x)
x = trimstring
Next
End Sub
Many thanks