+ Reply to Thread
Results 1 to 12 of 12

Repeat macro from user input

  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
    Please Login or Register  to view this content.
    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

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-14-2008
    Posts
    6
    Thanks for that, I'm using 2007.

    Just tried the macro you supplied, I get Compile Error: End If without block If

    I copied it and placed it like this:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The End If needed moving.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-14-2008
    Posts
    6
    That's great thanks very much, now just one thing

    Say a user types 10 in the input we need to half it so 5 sheets are printed. Bearing in mind that if they typed 9 we couldn't print 4.5 so we would print 5 instead. In excel I would use something like: =EVEN(A1)/2

    Can this be fitted into a macro?

    Thanks for all your help so far.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-14-2008
    Posts
    6
    Thats absolutely fantastic, Thanks very much royUK

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it helped.

+ 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