Excel macro - truncate cell at X characters (left to right)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Need to create a macro to be able to truncate the contents of cells at X
characters. X will always be the same value. X will be counted left to
right

Ex. If X = 5
ABC1234 would be truncated to ABC12
 
sub ABC()
Dim x as Long, cell as Range
x = 5
for each cell in selection
cell.Value = left(cell.Value,x)
Next
end sub
 
Back
Top