Stripping the alpha character from the left side of string...

Lidsavr

Active Member
Joined
Jan 10, 2008
Messages
330
I am running Excel 2007.

I have two values that contain 1 or 2 alpha characters and 1 to 5 numbers.

Example:
Cell J3 contains RN9999
Cell J4 contains RN10005
Cell J5 will contain the formula to subtract J4-J3. I then want to subtract a value of 1 from the answer.

I have tried:

Code:
=(J4-J3)-1

which returns a '#VALUE' error

Additionally, I've tried:

Code:
=(MAX(J3:J4)-MIN(J3:J4))-1

this returns an answer -1.

I think my best bet is to strip off the alpha characters but sometimes there is one alpha character and sometimes two. I am not sure how to account for this variable.

Can anyone help me with this?

Thank you,
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello, Try,

=LOOKUP(1E+307,CHOOSE({1,2},0,LOOKUP(1E+307,--RIGHT(J4,{1,2,3,4,5,6,7,8,9}))-LOOKUP(1E+307,--RIGHT(J3,{1,2,3,4,5,6,7,8,9}))-1))
 
Upvote 0
I am running Excel 2007.

I have two values that contain 1 or 2 alpha characters and 1 to 5 numbers.

Example:
Cell J3 contains RN9999
Cell J4 contains RN10005
Cell J5 will contain the formula to subtract J4-J3. I then want to subtract a value of 1 from the answer.

I have tried:

Code:
=(J4-J3)-1

which returns a '#VALUE' error

Additionally, I've tried:

Code:
=(MAX(J3:J4)-MIN(J3:J4))-1

this returns an answer -1.

I think my best bet is to strip off the alpha characters but sometimes there is one alpha character and sometimes two. I am not sure how to account for this variable.

Can anyone help me with this?

Thank you,
Put up in a general form...

J5:
Code:
=1+(REPLACE(J4,1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},J4&"0123456789"))-1,"")-
    REPLACE(J3,1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},J3&"0123456789"))-1,""))
 
Upvote 0
Dryver14,
Many thanks! I double-checked to ensure the formula works with 1 or 2 alpha characters and it does! I would like to understand the formula more, but for now, I can get my work done. You are a huge help!
 
Upvote 0
Mine shouldn't work with 1 alpha characters I dont think asit excludes the first 2 items from the number For that the other formulas posted are much better I think as they are seeking out alpha numeric characters
 
Upvote 0
Another solution, relies on there being only 1 or 2 letter prefixes
A1 is code
B1 =IF(ISNUMBER(VALUE(MID(A1,2,1))),VALUE(MID(A1,2,LEN(A1))),VALUE(MID(A1,3,LEN(A1))))
then do the maths using col B values
 
Upvote 0

Forum statistics

Threads
1,224,608
Messages
6,179,872
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top