A Simple Trim

  • Thread starter Thread starter N1KO
  • Start date Start date
N

N1KO

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).
 
Hi,

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

myvalue = Left(myvalue, 241)

Mike
 
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
 
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)
 
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
 
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

......"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.
 

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

Back
Top