Last 4 digit

P

puiuluipui

Hi, i need to extract the last 4 digit from a number.
ex:
A B
0788198256 8256
But if the first number of extracted 4 is zero, i need it to be transformed
into 1.
ex:
A B
0788190248 1248

Can this be done?
Thanks!
 
J

Jacob Skaria

=VALUE(IF(LEFT(RIGHT(A1,4),1)="0","1"&RIGHT(A1,3),RIGHT(A1,4)))

If this post helps click Yes
 
R

Ron Coderre

With A1 containing numeric text of at least 4 characters:

This formula returns the 4 right-most chars,
converting a leading zero to 1:
B1: =MAX(LEFT(RIGHT(A1,4)),1)&RIGHT(A1,3)

Examples:
0788198256.....8256
0788190256.....1256

Note: The returned values will be text.
If you need numbers returned, try this variation:
B1: =--(MAX(LEFT(RIGHT(A1,4)),1)&RIGHT(A1,3))

Is that something you can work with?

Regards,

Ron Coderre
Microsoft MVP (Excel)
 

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