• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA: How to remove spaces from a table column

inddon

Member
Hello There,

I have a table column (eg. "Name"). In some of the column cells the data contains blank spaces.

Could you please advise, how to remove the blank spaces in the Table-Column ("Name") using VBA? The value will always be a single name.

Table
Column
-------------
NAME
-------------
Peter
Sam ander
Rocky
P eter
Davi d


Many thanks & regards,
Don
 
Something like below.
Code:
Sub test2()
Dim tbl As ListObject

'Change as needed
Set tbl = Worksheets("Sheet1").ListObjects("Table1")
With tbl.ListColumns("Name").DataBodyRange
    .Replace What:=Chr(32), Replacement:=""
End With

End Sub
 
Back
Top