Macro/function that keeps in a cell a given number of characters

A

andrei

Many columns , many cells . Some with text ( including numbers , empt
spaces etc ) some with no content . I need a macro that keeps in a cel
a given number of characters ( the first 5 or first 10 characters ) an
delets the rest

Example :

I need the macro function to keep the first 11 characters

A1 : Mommy and daddy went home

The result should be :

A1: Mommy and
 
G

Gord Dibben

Truncate to 5, 10 or 11 characters?

How do you choose?

For your example.................

Sub trunc()
With ActiveCell
If Len(.Value) > 11 Then
.Value = Left(.Value, 11)
End If
End With
End Sub


Gord Dibben MS Excel MVP
 

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