2 DIGITS OUT OF 4

G

gregork

From a four digit number I want to have a formula that extracts only the
middle two numbers eg." 5062" would equal "06" or "4113" would equal "11".

GK
 
M

Michael Bednarek

From a four digit number I want to have a formula that extracts only the
middle two numbers eg." 5062" would equal "06" or "4113" would equal "11".

Perhaps I'm missing something, but doesn't
=MID(A1,2,2)
do that?
 
K

Ken Wright

The -- bit assumed you wanted numbers as stated, though you wouldn't get 06
which you also stated. If you really want a string returned then just skip
the -- bit.
 
H

Harald Staff

MID is a text function, so just for the fun of it a pure numeric approach
too:

=INT(MOD(A1,1000)/10)

Best wishes Harald
 
M

Michael Bednarek

MID is a text function, so just for the fun of it a pure numeric approach
too:

=INT(MOD(A1,1000)/10)

That MID() is a text function doesn't seem to matter - TEXT() seems
implied. To wit: =MID(5062,2,2) gives 06 which is what the OP wanted.

Your function omits the leading zero.
 
H

Harald Staff

That MID() is a text function doesn't seem to matter - TEXT() seems
implied. To wit: =MID(5062,2,2) gives 06 which is what the OP wanted.

Relax man. Solutions posted here are also archived and used by readers which
may have slightly different needs, so alternate approaches to a problem is
always good and nothing to get worked up about. I know your solution works
fine and that it probably solved the initial problem. Just wanted to say
that a text approach to number material is not the only way to go. Text
functions are e.g. nothing but trouble when we calculate date and time..
Your function omits the leading zero.

As we both know, 6 and 06 is the same number. Custom number format 00 will
display one digit integers with a leading zero.

Best wishes Harald
 
K

Ken Wright

The OP:-
^^^^^^
Harald:-
MID is a text function, so just for the fun of it a pure numeric approach
too:

As I pointed out, the original question was not succinct wrt exactly what
was to be returned, and besides that it was Saturday and Harald was bored.
:)
 
J

Jack Sons

Harald,
... Solutions posted here are also archived and used by readers which
may have slightly different needs

Yes, Over the years I did so 712 times! Learned a lot of all those posts and
answers and even could sometimes help somebody else with an item out of my
archive.

So please keep on doing the right thing, guys like me (not clever enough to
invent all those solutions myself, sometimes even not understanding them
fully) are grateful for it.

Jack Sons
The netherlands
 
Top