Trim Cells using VBA in Excel

后端 未结 8 1209
你的背包
你的背包 2020-12-11 03:02

I have what seems like a simple problem with some data in Excel. I have a lot of data with leading spaces pasted from a web table, and I would like to get rid of the initial

8条回答
  •  旧时难觅i
    2020-12-11 03:50

    Works fine for me with one change - fourth line should be:

    cell.Value = Trim(cell.Value)
    

    Edit: If it appears to be stuck in a loop, I'd add

    Debug.Print cell.Address
    

    inside your For ... Next loop to get a bit more info on what's happening.

    I also suspect that Trim only strips spaces - are you sure you haven't got some other kind of non-display character in there?

提交回复
热议问题