+ Reply to Thread
Results 1 to 2 of 2

Printing incremental value

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2019
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    2

    Printing incremental value

    I have been searching it for 5days already and now im desperate

    I have a problem on incrmenal cell value, what i want to achieve is to prnt a worksheet where the value inputed in a1 will automatically add 1 to cell e1
    a1=100 then e1 will be 101

    then this value will increase when i print 3 copies

    result will be
    a1 e1
    100 101

    next page
    a1 e1
    102 103

    and so on..

    im stuck on this
    Last edited by Pepe Le Mokko; 09-25-2019 at 02:45 AM. Reason: Remove unnecessary title part

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: Printing incremental value

    Hi there,

    See if the following code gets you moving in the right direction:

    
    
    Option Explicit
    
    
    Sub PrintWorksheet()
    
        Const sSHEET_NAME   As String = "Sheet1"
        Const sCELL_1       As String = "A1"
        Const sCELL_2       As String = "E1"
    
        Dim vNoOfCopies     As Variant
        Dim iNoOfCopies     As Integer
        Dim iCopyNo         As Integer
        Dim wks             As Worksheet
    
        vNoOfCopies = InputBox("How many copies do you want to print?")
    
        If IsNumeric(vNoOfCopies) Then
    
              Set wks = ThisWorkbook.Worksheets(sSHEET_NAME)
    
              iNoOfCopies = CInt(vNoOfCopies)
    
              For iCopyNo = 1 To iNoOfCopies
    
                  With wks
    
                      If iCopyNo > 1 Then
                          .Range(sCELL_1).Value = .Range(sCELL_1).Value + 1
                      End If
    
                      .Range(sCELL_2).Value = .Range(sCELL_1).Value + 1
    
                      .PrintOut 
    
                  End With
    
              Next iCopyNo
    
        Else
    
              If vNoOfCopies <> vbNullString Then
                  MsgBox "You did not enter a valid (integer) number of copies"
              End If
    
        End If
    
    End Sub
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

+ 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. Incremental changes
    By pjly29 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-17-2018, 04:35 AM
  2. Printing a Series of Excel Workbooks with Incremental Serial Numbers
    By bugmarker in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2015, 12:44 PM
  3. needhelp creating pricing sheet
    By Skygod49 in forum Excel General
    Replies: 7
    Last Post: 01-27-2014, 07:10 AM
  4. Incremental Addding
    By kitty7 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-27-2012, 06:31 AM
  5. Incremental Numbering
    By logiccircuits in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2007, 09:53 AM
  6. incremental counter
    By cynthiabryant in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-03-2006, 12:20 PM
  7. Incremental comparison
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02: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