How to remove spaces in between text?

后端 未结 10 743
日久生厌
日久生厌 2021-01-13 00:00

Why trim is not working in VBA?

for i = 3 to 2000
activesheet.cells(i,\"C\").value = trim(Activesheet.cells(i,\"C\").value)
next i

It is un

10条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 00:27

    I know this is quite old but thought I'd add in something else rather than all these replace options.

    Using trim (or trim$) in VBA will remove the leading and trailing spaces, which as mentioned is different from =TRIM in Excel.

    If you need to remove spaces (as mentioned below not necessarily all whitespace) from inside a string simply use WorksheetFunction.Trim.

提交回复
热议问题