VBA to add alpha character to duplicate records

hayleyzim

New Member
Joined
Jul 7, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello! I'm currently working on a spreadsheet where training is recorded. We're currently recording entries in two parts - First by training request, and then by courses scheduled. Each request is given a reference number, such as LT00001. Then each course is assigned an individual reference number, such as LT00001A, LT00001B, LT00001C, etc.
(Reason being is, we may get one training request, however there could be several different courses booked from that one request.)

The problem I'm having is that the formula I'm using only works for up to 26 duplicates (LT00001A to LT0001Z), but I'd like it to continue further (LT00001A all the way to LT0001ZZ).

I'm currently using the formula "=A4&CHAR(COUNTIF($A$4:A4,A4)+64)", which looks like this in the VBA:

.Range("B" & irow).Formula = "=A" & irow & "&CHAR(COUNTIF($A$4:A" & irow & ",A" & irow & ")+64)"

I'm not sure what to add to this formula in order to make this work, can anyone help please?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi & welcome to MrExcel.
This will take you up to ZZ
Excel Formula:
=LET(Qty,COUNTIFS(A$4:A4,A4)-1,in,INT(Qty/26),A4&IF(in,CHAR(in+64),"")&CHAR(MOD(Qty,26)+65))
 
Upvote 0
A simpler solution that will work up to XFD
Excel Formula:
=LET(Col,ADDRESS(1,COUNTIFS(A$4:A4,A4),4),A4&LEFT(Col,LEN(Col)-1))
 
Upvote 0
Solution
A simpler solution that will work up to XFD
Excel Formula:
=LET(Col,ADDRESS(1,COUNTIFS(A$4:A4,A4),4),A4&LEFT(Col,LEN(Col)-1))

That worked perfectly, thank you so much for your help!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

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