ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro/function that keeps in a cell a given number of characters (https://www.excelbanter.com/excel-programming/435487-macro-function-keeps-cell-given-number-characters.html)

andrei[_6_]

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

Many columns , many cells . Some with text ( including numbers , empty
spaces etc ) some with no content . I need a macro that keeps in a cell
a given number of characters ( the first 5 or first 10 characters ) and
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 d


--
andrei
------------------------------------------------------------------------
andrei's Profile: http://www.thecodecage.com/forumz/me...hp?userid=1056
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=148346


Gord Dibben

Macro/function that keeps in a cell a given number of characters
 
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

On Tue, 27 Oct 2009 17:14:06 +0000, andrei
wrote:


Many columns , many cells . Some with text ( including numbers , empty
spaces etc ) some with no content . I need a macro that keeps in a cell
a given number of characters ( the first 5 or first 10 characters ) and
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 d




All times are GMT +1. The time now is 08:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com