+ Reply to Thread
Results 1 to 11 of 11

Help please! Macro to add alpha character to duplicate records

  1. #1
    Registered User
    Join Date
    07-06-2021
    Location
    Australia
    MS-Off Ver
    Version 2104
    Posts
    9

    Help please! Macro to add alpha character to duplicate records

    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. I'm now trying to assign an individual reference number to each course scheduled, 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. I'm needing to add this into the current VBA macros, 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$" & irow & ":A" & irow & ",A" & irow & ")+64)"

    My issue now is that the macro is adding an "A" to each record, but not continuing on (so now I have three rows of LT00001A, instead of it going LT00001A, LT00001B, LT00001C).

    Annotation 2021-07-07 115257.png

    I really hope this makes sense, any help would be greatly appreciated!

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: Help please! Macro to add alpha character to duplicate records

    Looks like
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-10-2021
    Location
    Paryzevo
    MS-Off Ver
    2k3
    Posts
    60

    Re: Help please! Macro to add alpha character to duplicate records

    Quote Originally Posted by hayleyzim View Post
    to assign an individual reference number to each course scheduled, such as LT00001A, LT00001B, LT00001C, etc.
    What should be after the first 26 occurrences of a given Id from column "A", i.e. when the letters of the alphabet end ... and so on ?

  4. #4
    Registered User
    Join Date
    07-06-2021
    Location
    Australia
    MS-Off Ver
    Version 2104
    Posts
    9

    Re: Help please! Macro to add alpha character to duplicate records

    I've just tried to run that one and now it's leaving column B empty, I'm not sure if I put it in wrong though?

    I am wondering if there's a way to make it reference the cell above, if I could simply write the formula in column B I would use "=IF(A4=A3,(A4&(CHAR(CODE(RIGHT(B3,1))+1,(A4&"A"))", but I'm not sure how to recreate this in VBA.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: Help please! Macro to add alpha character to duplicate records

    Quote Originally Posted by hayleyzim View Post
    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$" & irow & ":A" & irow & ",A" & irow & ")+64)"
    NO,
    if should be
    Please Login or Register  to view this content.
    And you don't need to loop, so I posted the one line code.
    Add a period like
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-06-2021
    Location
    Australia
    MS-Off Ver
    Version 2104
    Posts
    9

    Re: Help please! Macro to add alpha character to duplicate records

    That worked perfectly! I've been tearing my hair out over this one, thank you so much!

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: Help please! Macro to add alpha character to duplicate records

    No problem.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  8. #8
    Registered User
    Join Date
    07-06-2021
    Location
    Australia
    MS-Off Ver
    Version 2104
    Posts
    9

    Re: Help please! Macro to add alpha character to duplicate records

    It does thank you! I've marked it as SOLVED.

    I did just think of another point I was hoping to run by you though... What if we needed more than 26 entries, is there a way to then make it continue on to LT00001AA, LT00001AB, etc? I'm not sure if we will need that many entries available, but I thought I'd check if it's possible before releasing this spreadsheet to the team.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: Help please! Macro to add alpha character to duplicate records

    You mean like this?
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-06-2021
    Location
    Australia
    MS-Off Ver
    Version 2104
    Posts
    9

    Re: Help please! Macro to add alpha character to duplicate records

    Is there a way to do it with this formula? It seems to be working the best with the spreadsheet.

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

    If not, I'm sure we can make it work with maximum 26 entries. Being able to make it continue onto LT00001AA, LT00001AB, LT00001AC etc. would just be a bonus!

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: Help please! Macro to add alpha character to duplicate records

    Quote Originally Posted by hayleyzim View Post
    If not, I'm sure we can make it work with maximum 26 entries. Being able to make it continue onto LT00001AA, LT00001AB, LT00001AC etc. would just be a bonus!
    That's what I posted.

    It allows you to go to XFD, 16384 entries for each single unique value.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Add an alpha character to duplicate entries
    By terreese in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-11-2023, 09:13 PM
  2. Duplicate RECORDS - Macro Requested
    By kishoremarodia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-31-2017, 04:57 AM
  3. [SOLVED] Macro to remove a duplicate, character, and add a hyperlink
    By wizmaster in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2017, 11:58 PM
  4. Update Duplicate records - macro
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2013, 11:28 AM
  5. [SOLVED] 3 Character Alpha Numeric Permutations
    By N8237 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2012, 10:00 PM
  6. Macro for duplicate records
    By savio21 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-16-2011, 03:03 PM
  7. add alpha character
    By thillis in forum Excel General
    Replies: 6
    Last Post: 11-10-2009, 01:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1