Reputation: 49
I am trying to trim all of the cells that have data in column C to the left most 9 characters.
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)
' getting syntax error on this line
Upvotes: 1
Views: 87
Reputation: 6829
Just use Left
?
Cells(1,1).value = Left(Cells(1,1).value,9)
This would be looped down the range:
For i = 1 to LastRow Step 1
Cells(i,3).value = Left(Cells(i,3).value,9)
Next i
Upvotes: 2