How do you trim characters?

T

Tommi

Hi there!

This is my first post, so please have mercy on my soul. :rolleyes:

In one cell I have a character string, e.g. 1011-1

I want to extract the 3rd and 4th character to a new cell, i.e. "11"
above, as a number.

I was thinking of using a trim-type function to remove the first two
characters and everything after (and including) the hypen. Problem: the
trim function seems to only remove spaces.

I'd like to do this in the little fx window rather than using anything
fancy like VBA.

Thanks for any help you can provide. :)
 
R

Roger Govier

Hi Tommi

With the value containing the string try
=MID(A1,3,2)
The 3 tells the Mid function to start at the 3rd character position
The 2 tells it to take 2 characters.

If you want the resulting 11 to be numeric instead of text, then precede
the formula with the double unary minus -- which will coerce the text
value to a number
=--MID(A1,3,2)
 
K

Ken Wright

Is your data all the same length?

If so then just copy your column to the next column, select all the data and
do data / text to columns / fixed width, put in breaks after the 2nd and 4th
characters, hit next and then click on first and last columns in the dialog
box and choose 'do not import'

Hit Ok and you are done.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------­------------------------------­----------------
It's easier to beg forgiveness than ask permission :)
------------------------------­------------------------------­----------------
 
R

Roger Govier

With the value containing the string try
That should have read
With A1 containing the string, try
=MID(A1,3,2)
 

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

Similar Threads

Formating bolded text exclusively. 0
Remove Identical words 0
Function =Trim() 5
TRIM FUNCTION...how to? 3
TRIM Q 3
Trim hidden characters? 3
SUMIFS with Trim 2
Remove non-space spaces? 3

Top