PDA

View Full Version : using Excel function TRIM rather than VBA function TRIM



clarksonneo
02-01-2011, 09:15 AM
Hi,

In the picture below, column d is the result I want.

In my code below, I can't produce the result I want, because VBA f TRIM is not same as Excel f TRIM.

Could you please amend my code so that I can produce the result I want?



Sub Remove_Excess_Space_()

For Each x In Selection

i = x.Row
x.Offset(0, 2) = Trim(Cells(i, 2).Value)

Next

End Sub



Thanks

Bob Phillips
02-01-2011, 09:25 AM
Sub Remove_Excess_Space_()

For Each x In Selection

i = x.Row
x.Offset(0, 2) = Application.Trim(Cells(i, 2).Value)

Next

End Sub