我正在尝试删除列中"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)