move first two digit to right

T

TFMR

Dear All,

I have a list of nos. 4-12456 and so on. I want to move first two character
to end of cell value like 12456-4.

Thanks & Regards

Hassan
 
M

Mike H

Hi,

We could have done with a few more examples but this works for your posted one

=MID(A1,3,LEN(A1))&MID(A1,2,1)&LEFT(A1,1)
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
L

Lars-Åke Aspelin

Dear All,

I have a list of nos. 4-12456 and so on. I want to move first two character
to end of cell value like 12456-4.

Thanks & Regards

Hassan

If you input is in cell A1, try the following in the cell where you
want to have your output:

=RIGHT(A1,LEN(A1)-2)&MID(A1,2,1)&LEFT(A1)

Hope this helps / Lars-Åke
 
P

Per Jessen

Hi Hassan

=MID(A1,3,99)&"-"&LEFT(A1,1)

Note that 99 is just an arbitrary number, which has to be equal to or larger
than your text string less two.

Regards,
Per
 
T

TFMR

Thanks Mike,

Its really help me, but there is one more query that if there is only five
digit without hypen "-" then return will be same.
 
M

Mike H

Hi,

As I said in my last post

Give examples of before and after and someone will come up with a generic
solution. There is no point in guessing further as to what your data looks
like
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
J

Joe User

TFMR said:
Its really help me, but there is one more query
that if there is only five digit without hypen "-"
then return will be same.

You are not being very clear about your requirements. If you strings are
only of the form x-xxxxx and xxxxx, then the following should suffice:

=if(len(A1)=5, A1, mid(A1,3,5) & "-" & left(A1))

Note: Change MID(A1,3,5) to MID(A1,3,99) if strings that start with "x-"
might be longer than 7 characters.


----- original message -----
 

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

Top