#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default A Simple Trim

I need to trim a series of cells so they only contain 241 characters. Does
anyone have any VBA code to make this quick and easy?

It needs to be the 1st 241 characters, everything else after that can be
deleted however i don't think i can use an =Right or =Trim to my knowledge as
the amount of characters in the cell isn't always the same (Anywhere between
40 & 390characters).
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default A Simple Trim

Hi,

It doesn't matter if there are less than 241 characters, this works

myvalue = Left(myvalue, 241)

Mike

"N1KO" wrote:

I need to trim a series of cells so they only contain 241 characters. Does
anyone have any VBA code to make this quick and easy?

It needs to be the 1st 241 characters, everything else after that can be
deleted however i don't think i can use an =Right or =Trim to my knowledge as
the amount of characters in the cell isn't always the same (Anywhere between
40 & 390characters).

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default A Simple Trim

On Wed, 11 Feb 2009 04:37:19 -0800, N1KO
wrote:

I need to trim a series of cells so they only contain 241 characters. Does
anyone have any VBA code to make this quick and easy?

It needs to be the 1st 241 characters, everything else after that can be
deleted however i don't think i can use an =Right or =Trim to my knowledge as
the amount of characters in the cell isn't always the same (Anywhere between
40 & 390characters).


What about =left(a1,241)

You could put that in a helper column, fill down, then copy/paste-values to get
rid of the formula and also replace the original.
--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 206
Default A Simple Trim

On Feb 11, 5:37*am, N1KO wrote:
I need to trim a series of cells so they only contain 241 characters. Does
anyone have any VBA code to make this quick and easy?

It needs to be the 1st 241 characters, everything else after that can be
deleted however i don't think i can use an =Right or =Trim to my knowledge as
the amount of characters in the cell isn't always the same (Anywhere between
40 & 390characters).


I beleive this should work

=IF(LEN(A1)241,LEFT(A1,241),A1)
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 206
Default A Simple Trim

"Oh Ya!, that's right what Mike said" , I replied foolishly


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default A Simple Trim

Hi,

If you go for a worksheet solution then there's no need to test if the
string is 241 long with an IF

=left(a1,241)

is sufficient even for shorter strings.

Mike

"CurlyDave" wrote:

"Oh Ya!, that's right what Mike said" , I replied foolishly

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 206
Default A Simple Trim

On Feb 11, 6:10*am, Mike H wrote:
Hi,

If you go for a worksheet solution then there's no need to test if the
string is 241 long with an IF

=left(a1,241)

is sufficient even for shorter strings.

Mike

"CurlyDave" wrote:
"Oh Ya!, that's right what Mike said" , I replied foolishly


......"Oh Ya!, that's right what Mike said" , I replied
foolishly........
I was agreeing with you, I couldn't believe I didn't think of it.
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
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
trim ferdy New Users to Excel 4 May 11th 05 11:10 AM
Make it more simple or intuitive to do simple things Vernie Charts and Charting in Excel 1 March 16th 05 04:01 AM


All times are GMT +1. The time now is 11:43 PM.

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

About Us

"It's about Microsoft Excel"