+ Reply to Thread
Results 1 to 11 of 11

Generate alphanumeric code based on date in cell

  1. #1
    Registered User
    Join Date
    10-21-2016
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    9

    Unhappy Generate alphanumeric code based on date in cell

    Hi all,

    I have been working on a way to figure out if a request (one row) is approved, an alphanumeric code is generated based on the date that request was approved.

    It should look like this "CR" + "YEARDATE-1" (so if I approve my first request in april 2017) the number generated should look like this CR201704-1. The last digit should be determined based on the already approved requests.

    No I am stuck because the date is lined to the system date and the last digit is lined to the row, but this gives a false image since row 17 mag give "17" in the end whereas I only approved three requests you see.

    This is the code I am using now:

    =IF($R15="","",IF($R15="Rejected","",IF($R15="Approved","CR"&YEAR(TODAY())&TEXT(MONTH(TODAY()),"00")&"-"&TEXT(ROW()-1,"0000")-13)))

    First row of the data is "15".

    Thank you all for your help on this one! It's really appreciated.

    Kind regards,

    Bram
    Attached Files Attached Files
    Last edited by Iuscogens; 05-05-2017 at 12:46 PM. Reason: Attachment

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Generate alphanumeric code based on date in cell

    Ever consider what happens to the calculated code next month or next year...?
    Last edited by cytop; 05-05-2017 at 12:34 PM. Reason: 13 words and 2 typos :(

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Generate alphanumeric code based on date in cell

    Can you upload sample file that mirror your data set setup?

  4. #4
    Forum Contributor
    Join Date
    01-05-2017
    Location
    New York
    MS-Off Ver
    Office 2016
    Posts
    206

    Re: Generate alphanumeric code based on date in cell

    --------------
    Last edited by Raphaelp; 05-05-2017 at 12:48 PM.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Generate alphanumeric code based on date in cell

    Can you attach the spreadsheet (Go Advanced>Manage Attachments)? Show only enough data so we can see what you are trying to do. (too big and it won't upload)

    One problem I see right away is you are trying to create static numbers but using the TODAY function. Every day your numbers will update to reflect today's date.
    I suggest a column where you can enter a static date (Helpful hint, CONTRL + ; will insert today's date as a static value) and then reference that cell in your formula

    I can't give more help until I see the workbook
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    10-21-2016
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    9

    Re: Generate alphanumeric code based on date in cell

    Quote Originally Posted by CK76 View Post
    Can you upload sample file that mirror your data set setup?
    I added the attachment in my initial question. I suppose it should start counting from 1.

  7. #7
    Registered User
    Join Date
    10-21-2016
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    9

    Re: Generate alphanumeric code based on date in cell

    Hi there, thanks for your swift reply. I had to clean it up a bit, but you can find the attachment in my initial question. Hope this will make things clear.
    Regards,

  8. #8
    Registered User
    Join Date
    10-21-2016
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    9

    Re: Generate alphanumeric code based on date in cell

    Quote Originally Posted by ChemistB View Post
    Can you attach the spreadsheet (Go Advanced>Manage Attachments)? Show only enough data so we can see what you are trying to do. (too big and it won't upload)

    One problem I see right away is you are trying to create static numbers but using the TODAY function. Every day your numbers will update to reflect today's date.
    I suggest a column where you can enter a static date (Helpful hint, CONTRL + ; will insert today's date as a static value) and then reference that cell in your formula

    I can't give more help until I see the workbook
    I just did :-) in my initial question.
    Regards,

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Generate alphanumeric code based on date in cell

    Try this in U15 copied down.
    I assume that if rows are empty (because of "Rejected" in R) then you wouldn't want to skip numbers.

    =IF($R15="","",IF($R15="Rejected","",IF($R15="Approved","CR"&YEAR(S15)&TEXT(MONTH(S15),"00")&"-"&TEXT(SUMPRODUCT(--($U$14:$U14<>""))+1,"0000"))))

  10. #10
    Registered User
    Join Date
    10-21-2016
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    9
    Quote Originally Posted by ChemistB View Post
    Try this in U15 copied down.
    I assume that if rows are empty (because of "Rejected" in R) then you wouldn't want to skip numbers.

    =IF($R15="","",IF($R15="Rejected","",IF($R15="Approved","CR"&YEAR(S15)&TEXT(MONTH(S15),"00")&"-"&TEXT(SUMPRODUCT(--($U$14:$U14<>""))+1,"0000"))))
    O M G!!! IT WORKS!!! Thank you so much for your time and effort. Have a nice Sunday.
    Bram

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Generate alphanumeric code based on date in cell

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


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Need macro to generate a list of alphanumeric chars
    By MagPower in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-26-2016, 12:43 PM
  2. Replies: 0
    Last Post: 01-30-2016, 11:49 AM
  3. [SOLVED] Generate Dates by Month along columns based on Start Date and End Date
    By Stndsh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2015, 05:32 AM
  4. Generate random Alphanumeric with two letters and three numbers
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2015, 09:19 PM
  5. [SOLVED] Creating a formula to generate an alphanumeric code
    By JuauM in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-13-2015, 05:17 AM
  6. [SOLVED] Lookup Last Value then Generate Next Alphanumeric Value
    By jeversf in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2014, 10:35 PM
  7. [SOLVED] Formula to Derive Date from Alphanumeric Code
    By gmarie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-16-2013, 09:50 AM

Tags for this Thread

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