Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of characters in a cell for a Index/match function Govind Excel Worksheet Functions 11 May 6th 09 08:37 AM
Function to show the greatest number of characters juliejg1 Excel Worksheet Functions 4 December 12th 07 12:13 AM
Keep specified number of characters at end of cell? Kevin Excel Worksheet Functions 1 July 20th 07 04:40 PM
Max number of characters in a cell Dajana Excel Discussion (Misc queries) 1 September 25th 05 10:41 PM
Is there a rule for number of variables and characters used in a function Dave[_2_] Excel Programming 0 February 16th 05 03:03 PM


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"