Subtract 1 from a character in a number

afrantz

New Member
Joined
Oct 8, 2015
Messages
8
Good day, all

I need a formula that will allow me to subtract, and sometimes add, the 13th character by 1.

So this number here:
22222-222-A22ZQ

I need to change to:
22222-222-A21ZQ

And sometimes (if it matters), I'll need to change this number:
22222-222-A22

To this number:
22222-222-A21

I've done a lot of searches using terms like "Excel subtract a number in a string by one -date -convert" and various combinations of this but can't find anything like what I want. I realize this function may be unusual and possibly simple.

Thank you!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If it's always the 13th character, try

=REPLACE(A1,13,1,MID(A1,13,1)-1)

Now what if the 13th character was a 0 ?
Or a 9 if you're ADDING instead of subtracting ?
 
Upvote 0
It can sometimes be the 14th but mostly the 13th. And the formula would not be needed if the 13th character was a 0. Only if it's greater than 0.

That formula works! Thank you!
 
Upvote 0
Assuming its the 13 character then try this: =LEFT(C1,11)& (--MID(C1,12,2)+A1) & MID(C1,14,255) I've assumed that the 22 (12th&13th characters) are a single number and hence can be incremented or decremented at will, I've also assumed that the number you want to increment/decrement by is in A1.
 
Upvote 0
no problem, my pleasure to have helped and thatnks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,668
Members
449,463
Latest member
Jojomen56

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