小编Ale*_*lon的帖子

如何使用VBA从整个Excel列中删除空格?

我正在尝试删除列中"A"的每个字段中的空格.这个空格位于字符串的末尾,一些字符串有3个空格,其他4.当我运行代码时,我没有错误,所以我认为我有一个错误,因为运行时没有任何反应.

Dim result As String
Last = Cells(Rows.Count, "A").End(xlUp).Row
    For i = Last To 1 Step -1
      If (Right(Cells(i, "A").Value, 4)) Like "    " Or (Right(Cells(i, "A").Value, 3)) Like "   " Then
        result = Replace(Cells(i, "A"), " ", "")
    End If
Next i
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

3
推荐指数
2
解决办法
3万
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1