我正在尝试将 C 列中包含数据的所有单元格修剪到最左边的 9 个字符。
Sub TrimColumns()
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
If LastRow > Columns("B").Row Then
Range("C2:C" & LastRow).LTrim(1,9) ' getting syntax error on this line
End If
End Sub
Range("C2:C" & LastRow).LTrim(1,9)
' 在这一行出现语法错误
最佳答案
只需使用 Left
?
Cells(1,1).value = Left(Cells(1,1).value,9)
这将在范围内循环:
For i = 1 to LastRow Step 1
Cells(i,3).value = Left(Cells(i,3).value,9)
Next i
关于excel - 使用 Trim 功能删除不需要的多余字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56636301/