Incremental number increase in alphanumeric text

tanyaslater

New Member
Joined
Oct 13, 2015
Messages
8
I am looking for a formula (preferably a formula rather than a macro as generally whenever I run a macro it crashes Excel and I lose all my changes) that will allow me to incrementally increase a number within a string of alphanumeric text horizontally across columns.

I have a column of serial numbers for a range of items that apply to 1 part of a construction. That construction is then replicated so i need to replicate the serial numbers but incrementally increase the number that indicates the order of construction i.e. my first column is as below:

CUB-1-F1
CUB-1-FA
CUB-1-FB
CUB-1-FC
CUB-1-B1
CUB-1-B2
CUB-1-B3
CUB-1-B4

<!--StartFragment--> <colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--EndFragment--></tbody>

the next column needs to be identical with the exception of the fact that I need to replace the first 1 with a 2 i.e. CUB - 1 becomes CUB-2

CUB-2-F1
CUB-2-FA
CUB-2-FB
CUB-2-FC
CUB-2-B1
CUB-2-B2
CUB-2-B3
CUB-2-B4

<!--StartFragment--> <colgroup><col width="65" style="width:65pt"> </colgroup><tbody>
<!--EndFragment--></tbody>


I've tried to drag the handle across but it just copies and replicates the first two columns and I can't figure out how to incrementally increase the number.

Any hlep would be much appreciated.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Tanya, welcome to the boards.

Assuming that CUB-1-F1 is in cell A1 of your worksheet, try this in cell A2, then drag across:

=LEFT(A1,4)&(MID(A1,5,1)+1)&RIGHT(A1,3)

[EDIT] - This only works so long as the number in the middle doesn't need to go above 10, e.g CUB-10-F1 is the end. If it has to go higher than 10 you will need an alternative formula instead of this one.
 
Upvote 0
Hey there

Thanks so much for the response but unfortunately I do need it to go higher than 10 - I need to extend it up to 49.
 
Upvote 0
Welcome to the MrExcel board!

Is the prefix ("CUB" in this case) always 3 characters long?
Is the suffix always 2 characters long as in your sample?
 
Upvote 0
Hi there

Yes the prefix is always 3 letters long but the suffix can vary depending on the item

Many thanks

Tanya
 
Upvote 0
Hi there

Yes the prefix is always 3 letters long ...
In that case try this copied across & down.

Excel Workbook
ABCDEFGHIJK
1
2CUB-1-F1CUB-2-F1CUB-3-F1CUB-4-F1CUB-5-F1CUB-6-F1CUB-7-F1CUB-8-F1CUB-9-F1CUB-10-F1CUB-11-F1
3CUB-1-FACUB-2-FACUB-3-FACUB-4-FACUB-5-FACUB-6-FACUB-7-FACUB-8-FACUB-9-FACUB-10-FACUB-11-FA
4CUB-1-FBCUB-2-FBCUB-3-FBCUB-4-FBCUB-5-FBCUB-6-FBCUB-7-FBCUB-8-FBCUB-9-FBCUB-10-FBCUB-11-FB
5CUB-1-FCCUB-2-FCCUB-3-FCCUB-4-FCCUB-5-FCCUB-6-FCCUB-7-FCCUB-8-FCCUB-9-FCCUB-10-FCCUB-11-FC
6CUB-1-B1CUB-2-B1CUB-3-B1CUB-4-B1CUB-5-B1CUB-6-B1CUB-7-B1CUB-8-B1CUB-9-B1CUB-10-B1CUB-11-B1
7CUB-1-B2CUB-2-B2CUB-3-B2CUB-4-B2CUB-5-B2CUB-6-B2CUB-7-B2CUB-8-B2CUB-9-B2CUB-10-B2CUB-11-B2
8CUB-1-B3CUB-2-B3CUB-3-B3CUB-4-B3CUB-5-B3CUB-6-B3CUB-7-B3CUB-8-B3CUB-9-B3CUB-10-B3CUB-11-B3
9CUB-1-B4CUB-2-B4CUB-3-B4CUB-4-B4CUB-5-B4CUB-6-B4CUB-7-B4CUB-8-B4CUB-9-B4CUB-10-B4CUB-11-B4
Increment
 
Upvote 0
Another option :

In B2, copy across & down :

=SUBSTITUTE($A2,"-1","-"&COLUMNS($A2:B2))

Regards
 
Upvote 0
Another option :

In B2, copy across & down :

=SUBSTITUTE($A2,"-1","-"&COLUMNS($A2:B2))

Regards
This looks good to me provided the "middle number" always starts at 1 - which it seems is the case.
Two remarks:

We are dealing with numbers so we could eliminate the quote marks & concatenation.

Given that the final part of the codes do contain numbers, just in case you might ever get an initial code like "CUB-1-1F", it might be worth adding the final argument to ensure only 1 substitution is made.

So possibly
=SUBSTITUTE($A2,-1,-COLUMNS($A2:B2),1)
 
Upvote 0

Forum statistics

Threads
1,221,446
Messages
6,159,917
Members
451,603
Latest member
SWahl

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