+ Reply to Thread
Results 1 to 5 of 5

Code to increment cell value between 2 given values and then print

  1. #1
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Code to increment cell value between 2 given values and then print

    Good afternoon all,

    I have a game scoresheet that draws team info from another worksheet which holds the competition draw based on the game number.
    I need to go through and print out a heap of scoresheets (over 100) but want to print them in batches dependent on where we are at in the competition. (eg Round 1 will be games 1 to 20.)

    I have tried the below code to do the following:

    Asks for the first game number to print
    Asks for the last game number to print
    Goes through and gradually increments cell A5 by 1 each time, prints the sheet and to stop once it prints the value entered into the last game number.

    So as an example, if I enter the Start Game to be game 2, and end Game to be game 5, I want the value in cell A5 to start at 2, get printed, increment to 3, get printed, and so on until it prints out a sheet with cell A5 having the value of 5.

    I have attached an example sheet using a basic vlookup to show when the values change as a test environment.

    I am running into trouble where I cannot get the number in cell A5 to gradually increment.

    Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Handy things to keep in mind:

    Click *, if my suggestion has helped you
    If your problem is solved, then please mark the thread as SOLVED

    Sharing is Caring .... spread the knowledge

  2. #2
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Code to increment cell value between 2 given values and then print

    Remove "myPrintValue = myPrintValue + 1"
    Your FOR NEXT loop is already incrementing this value by 1.

  3. #3
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Code to increment cell value between 2 given values and then print

    Thank you Ed_Collins ..... I am just starting to experiment with VBA and such a simple thing had thrown me.
    That worked perfectly.

    Do you happen to know the code to select the next item in a data validation list?
    Another part of my workbook is to print out a copy of the draw for each team and highlight their games. I have put the teams in a data validation list selected in cell B40. The list of team names is in cells X4:X23

    In short i just want to insert a button and apply a macro to it that means I can hit the button and it will select the first team, print the draw, then drop down to the next team and print the draw, and so on for the whole 20 teams without me having to manually select the team each time.

    This process just highlights their own team using Conditional formatting so they can see where they have to play in the draw.

  4. #4
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Code to increment cell value between 2 given values and then print

    Would you believe after typing my reply, but before hitting send, my electricity died? That never happens here. I now have to type this all over again. Fortunately, my answer is short.


    Anyway, no problem. Glad it worked.

    Yes, it sounds as if you just need another simple FOR NEXT loop. Something like:

    number_of_teams = 20
    Please Login or Register  to view this content.
    I assume that once cell B40 contains the name of a new team, other cells with formulas populate themselves with new data.

  5. #5
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Code to increment cell value between 2 given values and then print

    Fantastic thanks again .. .worked a treat

+ 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. Increment Alphanumeric Value of a Cell on each print job
    By rudygortiz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2014, 03:55 PM
  2. Excel VBA Code for Auto Increment Values
    By fakehealer in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-27-2013, 03:46 AM
  3. [SOLVED] Macro to Increment and Print to PDF filename from merged cell
    By ahjualune in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2012, 06:24 AM
  4. Print Sheet, Increment Cell Formula, Repeat.
    By K_Dub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2011, 11:46 AM
  5. [SOLVED] How do I auto increment cell value on print in Excel
    By Hiren in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-25-2005, 03:06 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