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

E

E2goJJM

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top