+ Reply to Thread
Results 1 to 15 of 15

Prefix - Suffix Macro

  1. #1
    Forum Contributor
    Join Date
    04-14-2017
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    148

    Prefix - Suffix Macro

    Hello

    I would like generate an order number with a Suffix and Prefix
    Format is as follows: MFJ10062014567
    MFJ = Prefix
    10062021 = Current Date
    4567 - Random 4 digits

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Prefix - Suffix Macro

    Would this work? or do you need a macro?

    ="MFJ"&TEXT(NOW(),"ddmmyyyy")&RANDBETWEEN(0,1000)
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  3. #3
    Forum Contributor
    Join Date
    04-14-2017
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    148

    Re: Prefix - Suffix Macro

    HI

    Thanks for your response, appreciate a macro , thanks

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,234

    Re: Prefix - Suffix Macro

    change 1000 to 9999
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Prefix - Suffix Macro

    I think you you will find that you will need to use a Macro.

    What you want can be achieved using a formula ="MFJ" & TEXT(TODAY(),"ddmmyyyy")&TEXT(RANDBETWEEN(1,9999),"0000")

    However you will need to check for duplicates so you will need to store all Invoice numbers and rerun the formula if you have a duplicate.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  6. #6
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Prefix - Suffix Macro

    I have created 2 routines in the attached, one is the macro alone and the other is a function so you can call it in a sheet
    and have it return the number

    In the attached on the sheet the function is used for your review.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-14-2017
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    148

    Re: Prefix - Suffix Macro

    HI

    I downloaded sample you sent, and tried running macro, which does not seem to work.

  8. #8
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Prefix - Suffix Macro

    Quote Originally Posted by farhadj View Post
    HI

    I downloaded sample you sent, and tried running macro, which does not seem to work.
    If you are referring to my file, what is it doing?

    The macro routine is only setup to display the results in the immediate window..
    The function can be called in the sheet itself as seen on sheet1

    Pick a cell and type:
    =RanorderNumber()

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,234

    Re: Prefix - Suffix Macro

    which does not seem to work.
    Works perfectly...If you know how to use it...

  10. #10
    Forum Contributor
    Join Date
    04-14-2017
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    148

    Re: Prefix - Suffix Macro

    Hi


    Keyed in =RandorderNumber() in Cell F21 and getting #NAME? error

  11. #11
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Prefix - Suffix Macro

    I just typed it in the file i upload in F21 and works

    ive uploaded the same file with the function called in F21

    Screenshot 2021-06-10 142349.jpg
    Attached Files Attached Files
    Last edited by cubangt; 06-10-2021 at 03:24 PM.

  12. #12
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Prefix - Suffix Macro

    Quote Originally Posted by farhadj View Post
    Keyed in =RandorderNumber() in Cell F21 and getting #NAME? error
    Where did you put the code? It must be placed in a general Module.

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Prefix - Suffix Macro

    Sorry guys.

    You have made no effort to avoid duplicate Invoice numbers.

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    04-14-2017
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    148

    Re: Prefix - Suffix Macro

    HIO

    My bad, it works, was typing in something incorrect initially . Thanks a million for you assistance , Sir
    Regards

  15. #15
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Prefix - Suffix Macro

    Quote Originally Posted by mehmetcik View Post
    You have made no effort to avoid duplicate Invoice numbers.
    This will guarantee no duplicates are generated...
    Please Login or Register  to view this content.

+ 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. prefix and suffix fixed value
    By sradjend in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-12-2019, 11:50 PM
  2. Prefix and Suffix Help
    By Scott Holmes in forum Excel General
    Replies: 3
    Last Post: 10-06-2015, 11:58 AM
  3. [SOLVED] Macro to add prefix and suffix to cell
    By heavy_metal_rckr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2013, 11:48 AM
  4. How to add prefix and suffix to a cell?
    By adi26 in forum Excel General
    Replies: 2
    Last Post: 08-28-2009, 03:21 AM
  5. Add Suffix & Prefix
    By di22y in forum Excel General
    Replies: 1
    Last Post: 06-25-2009, 06:34 PM
  6. adding prefix and suffix macro
    By justix in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 01-10-2007, 06:14 AM
  7. Prefix and Suffix
    By Clare in forum Excel General
    Replies: 2
    Last Post: 01-30-2006, 03:30 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