+ Reply to Thread
Results 1 to 9 of 9

Printing a Series of Excel Workbooks with Incremental Serial Numbers

  1. #1
    Registered User
    Join Date
    11-10-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    5

    Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Hello,

    I have been through the forum and haven't found a solution for a problem with all of the following elements:

    REQUIREMENTS
    1.) Require prompts that ask for a range of serial numbers (i.e. "What is the serial starting value?" "What is the serial ending value?")
    2.) Prints the workbook with the starting serial number, increments the serial number and prints again. Continues to loop until the range as given in #1 is completed.
    3.) Serials contain a non-numeric character. Serials begin with '01-', '02-', or '03-' and are followed by 5 digits (i.e. 01-00141).

    EXPLANATION
    I have a workbook that contains a serial number that exists in cell D5 throughout all worksheets in a workbook. I need an easy way to incrementally print a large series of these work books. For example, if a job comes in for 500 parts we will need 500 print outs of this workbook with serials starting with 01-00141 and ending with 01-00641. Instead of entering the serial, printing, and manually changing the serial and printing again it would be nice to have a macro that would do this for me.

    I have some experience with macros but it is mostly restricted to tweaking code. Any assistance would be appreciated.

    Thank you!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Hi bugmarker,

    Welcome to the Forum!

    Are we talking about printing 500 copies of one worksheet from one workbook with incremented serials in D5?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,946

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    You have to be careful because Excel may interpret 01-00010 as January 10, not as a string. So try this, entering and selecting as prompted. I did not hard code D5 as the range in case you need to do this on other sheets or if you change the sheet.

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    11-10-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    5

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Thank you all!

    I did find a solution, can you advise if this is 'best practice' or if I am coding the long way around the barn?
    Sorry...I don't know how to do the nifty screen with the code... :-/


    Sub SerialPrintAndIncrement()

    Range("SERIAL").Select

    'If the last 3 digits are less than 999 (hundreds place), then increment the last 3 digits (to keep the leading zeros in place)
    If Right(ActiveSheet.Range("SERIAL"), 3) < 999 Then
    ActiveSheet.Range("SERIAL") = Left(ActiveSheet.Range("SERIAL"), 5) & Mid(ActiveSheet.Range("SERIAL"), 6, 3) + 1

    'If the last 4 digits are less than 9999 (thousands place), then increment the last 4 digits (to keep the leading zeros in place)
    ElseIf Right(ActiveSheet.Range("SERIAL"), 4) < 9999 Then
    ActiveSheet.Range("SERIAL") = Left(ActiveSheet.Range("SERIAL"), 4) & Mid(ActiveSheet.Range("SERIAL"), 5, 4) + 1

    'If greater than 9,999 then increment the last 5 digits
    Else
    ActiveSheet.Range("SERIAL") = Left(ActiveSheet.Range("SERIAL"), 3) & Mid(ActiveSheet.Range("SERIAL"), 4, 5) + 1

    End If

    ActiveWorkbook.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

    End Sub
    Last edited by bugmarker; 11-12-2015 at 02:32 PM.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,946

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    That will work, but it does not meet either of your first two requirements.

    1.) Require prompts that ask for a range of serial numbers (i.e. "What is the serial starting value?" "What is the serial ending value?")
    2.) Prints the workbook with the starting serial number, increments the serial number and prints again. Continues to loop until the range as given in #1 is completed.

    Did you try my code?

  6. #6
    Registered User
    Join Date
    11-10-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    5

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    I have the code that appears to be working posted at the bottom of this string. I'd appreciate any feedback on the quality of the coding!

    Thank you, xladept!

  7. #7
    Registered User
    Join Date
    11-10-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    5

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Quote Originally Posted by Bernie Deitrick View Post
    That will work, but it does not meet either of your first two requirements.

    1.) Require prompts that ask for a range of serial numbers (i.e. "What is the serial starting value?" "What is the serial ending value?")
    2.) Prints the workbook with the starting serial number, increments the serial number and prints again. Continues to loop until the range as given in #1 is completed.

    Did you try my code?
    Thank you Bernie!!
    I actually put something together before you posted your code.
    To answer the question, I put another macro together that asks for the number of serials to print, it then calls the incrementing macro above and loops that way. After trying your code, I think it is a lot more straight forward! A couple quick questions:

    1. Can we have a message box that pops up to confirm the number of serials to print ("You will be printing 200 serials, are you sure you want to continue?")? Just as a safe guard? I have the following code but I'm struggling with it popping up each time it sends to the printer:

    If MsgBox("You selected to print " & iEnd - iStart & " serials, is this correct?", vbYesNo) = vbNo Then
    MsgBox ("Your print job has been cancelled.")
    Exit Sub

    2. Is there some way to prompt a correction if the input is anything other than 5 characters (the number of ending digits will ALWAYS be a sequence of 5)?


    Thank you for your patience!!
    Last edited by bugmarker; 11-13-2015 at 11:28 AM.

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,946

    Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Sure - try this one:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-10-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    5

    Cool Re: Printing a Series of Excel Workbooks with Incremental Serial Numbers

    Quote Originally Posted by Bernie Deitrick View Post
    Sure - try this one:
    BEAUTIFUL!! I tweaked it a little bit by sandwiching the code between these two bits to hide the processing from the user:

    Please Login or Register  to view this content.
    Thanks again, Bernie!! You da boss!

+ 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. Print Serial Numbers In Excel Spreadsheet
    By dizjackson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-14-2013, 09:24 AM
  2. Generating incremental serial numbers on each mouse click
    By pglen in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 08-07-2012, 09:11 PM
  3. Generating incremental serial numbers on each mouse click
    By pglen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-07-2012, 08:50 PM
  4. Excel Macro - Help need to group serial numbers
    By BazCham in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2012, 01:16 AM
  5. Incremental number series
    By Ashly in forum Excel General
    Replies: 2
    Last Post: 12-02-2011, 06:36 AM
  6. Excel formula for ascending serial numbers
    By joyfish2 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-04-2010, 05:57 PM
  7. Finding a serial number in a list of serial numbers
    By zocoloco in forum Excel General
    Replies: 2
    Last Post: 02-04-2009, 05:20 AM
  8. [SOLVED] serial numbers excel
    By JpBar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-29-2006, 06:00 PM

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