+ Reply to Thread
Results 1 to 6 of 6

Macro to generate a unique number on a shared workbook.

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    66

    Question Macro to generate a unique number on a shared workbook.

    Hi,

    I am totally new to macro but I believe that my problem can be solved using a simple macro.

    My requirement is as below:

    I have a shared workbook (which is used by approx 25 people). This workbook should have a macro assigned to a button which when clicked should generate a unique number starting from 1000. I believe the challange here is the shared workbook. As this workbook will be open with all the people there shouldn't be any duplicate numbers in case if two or more people press the button at the same time.

    FYI- I do not need a random number every time the button is clicked, just the next number in series will suffice.

    I would appreciate if the macro also has an explanation along with as this would help me better understand it and learn a few things too.

    Thanks in advance.

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

    Re: Macro to generate a unique number on a shared workbook.

    Hi

    The attached code should get you started.

    You need two files to make this work. The one containing the macro and one where A1 is your last used number.
    The one with the number is not opened but is updated. Not sure if this will work in your scenario but it is worth checking.




    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-29-2013 at 02:50 PM.

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Macro to generate a unique number on a shared workbook.

    I removed the .Close True as it was closing the workbook once the macro runs. I have assigned the macro to a button and it works verry nicely. Thank you verry much for the explanations it really helped me understand the code. 1 more request can we tell the macro to save the workbook once the button is clicked?

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

    Re: Macro to generate a unique number on a shared workbook.

    I have edited the code above for you.

  5. #5
    Registered User
    Join Date
    06-07-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Macro to generate a unique number on a shared workbook.

    Thanx for the quick response... Do I need to save the shared workbook as a macro enabled workbook (.xlsm) or should it be saved as normal (.xlsx)?
    Please guide me if I am doing something wrong...

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

    Re: Macro to generate a unique number on a shared workbook.

    Hi the workbook that the user modifies needs to be macro enabled.

    The Master file where the number is stored does not need to be macro enabled.

+ 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] Generate an unique ticket number and create a log
    By city in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2012, 06:35 AM
  2. Macro to generate next number from last cell of another workbook
    By larzep in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 03-06-2012, 02:12 AM
  3. Generate unique number
    By adeleex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2011, 08:46 AM
  4. Generate a unique number of list
    By Terence Chan in forum Excel General
    Replies: 3
    Last Post: 09-14-2005, 02:48 AM
  5. Generate a unique form number
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-18-2005, 09:05 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