Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Tink
 
Posts: n/a
Default Problem with counting characters in a cell

Hi,

I'm trying to count the number of characters in a cell. At the moment i've
tried using =LEN(A2). This works fine when all characters are numeric, but
when there are letters in the mix, it shows the total number as 30 regardless
of whether there are 8, 12 or 14 characters in the code.

Someone please help!!!
  #2   Report Post  
bj
 
Posts: n/a
Default

There may really be 30 characters
If this is data which has come in from an outside sourse there may be spaces
try
=len(trim(A2))
You may have to modify how the cells are referenced or handeled if this is a
significant issue.



"Tink" wrote:

Hi,

I'm trying to count the number of characters in a cell. At the moment i've
tried using =LEN(A2). This works fine when all characters are numeric, but
when there are letters in the mix, it shows the total number as 30 regardless
of whether there are 8, 12 or 14 characters in the code.

Someone please help!!!

  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

It should work ok with alph/numeric values.

I'd bet you have some extra spaces (or non-breaking spaces) in those cells.

=len(trim(substitute(a1,char(160)," ")))

might show you the problem.

If it turns out that you have spaces (or those non-breaking spaces), David
McRitchie has some code that will help clean this junk up:

http://www.mvps.org/dmcritchie/excel/join.htm#trimall
(look for "Sub Trimall()")

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Tink wrote:

Hi,

I'm trying to count the number of characters in a cell. At the moment i've
tried using =LEN(A2). This works fine when all characters are numeric, but
when there are letters in the mix, it shows the total number as 30 regardless
of whether there are 8, 12 or 14 characters in the code.

Someone please help!!!


--

Dave Peterson
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
Cell problem Patrick Excel Worksheet Functions 3 March 29th 05 04:33 PM
counting Multiple answers in 1 cell + column the6thlee Excel Discussion (Misc queries) 1 February 21st 05 10:19 AM
counting Multiple answers in 1 cell + column help me i have an excel problem Excel Discussion (Misc queries) 0 February 21st 05 09:41 AM
limit number of characters in a cell abfabrob Excel Discussion (Misc queries) 9 February 11th 05 05:19 PM
#### error if cell has more than 255 characters Budalacovyek Excel Discussion (Misc queries) 1 December 8th 04 07:42 PM


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

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"