View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Function/Macro that keeps first X characters in a cell and delets rest

Let's assume your cell is A1; this line of code should accomplish what you
want...

Range("A1").Value = Left(Range("A1").Value, 8)

Since this changes the value in the cell itself, you cannot use a UDF (User
Defined Function), so I'm guessing you will want to use it in a macro. Your
description (as to how you wanted your code to perform) was not detailed
enough to decide how to structure the macro for you.

--
Rick (MVP - Excel)


"andrei" wrote in message
...

So , i need a macro/function that keeps the first X characters in a cell
( the number is given ) and deletes the remaining characters

Example

In a cell i have the following text : *Mother and father*
I want the macro to keep the first 8 characters . So , in that cell ,
the result should be : *Mother a* . When i mean charcaters , i take into
consideration letter , space or number


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

Microsoft Office Help