+ Reply to Thread
Results 1 to 12 of 12

Repeat macro from user input

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2008
    Posts
    6

    Repeat macro from user input

    Hi,

    I have a very simple macro for recalculating formulas and printing the page.

    I need a way to show an input box where the user can say how many times to repeat the process i.e. 2x = recalculate, print, recalculate, print.

    Thanks in advance

    Edit: The input number needs to be rounded to even then halved before repeating
    Last edited by traxwriter; 06-14-2008 at 11:33 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Can you post your code - remember to use Code Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-14-2008
    Posts
    6
    Sub Macro6()
    '
    ' Macro6 Macro
    '
    
    '
        Calculate
        ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
    End Sub
    As I said simple code, actually I recorded it lol.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What's the purpose of it? Calculation is automatic unless you have switched it off in Options. tt uses an Excel4 macro and I don't know how you recorded that.

  5. #5
    Registered User
    Join Date
    06-14-2008
    Posts
    6
    The purpose of it is the recalculate several RANDBETWEEN formulas so each page printed is different. I recorded it in the usual way by pressing record macro, pressing F9, Control P and enter.

    Edit: SImply printing 50 copies produces the same sheets wihtout recalculating the forumlas in between copies
    Last edited by traxwriter; 06-14-2008 at 01:00 PM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What version of Excel are you using?

    This should do what you want

    Dim n      As Integer
        Dim x      As Integer
        n = Application.InputBox("How many copies?")
        If n > 0 Then
            For x = 1 To n
                Calculate
                ActiveSheet.PrintOut Copies:=1, Collate:=True
                End If
            Next x

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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