+ Reply to Thread
Results 1 to 12 of 12

Randomize a module with a sub of calling other subs.

  1. #1
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Randomize a module with a sub of calling other subs.

    Basically I have

    Sub example()

    Call Another module.sub1

    Call Another module2.sub2

    Call Another module3.sub3

    Call Another module4.sub4

    Call Another module5.sub5

    End Sub

    now if ran you know above runs 1 then 2 then 3 then 4 then 5 done..

    Is there a page or link I could go to to show me how to create it to completely randomly pick 5 2 3 4 1 or 3 1 2 5 4 or any way it wants to randomize

    BUT! it has to by the end when its finished have ran all 5 regardless the order. All 5 must be ran.

    Thanks for any input.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Randomize a module with a sub of calling other subs.


    See CallByName function in VBA inner help …

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,024

    Re: Randomize a module with a sub of calling other subs.

    Try something like this...
    In A1:A5 ... 1 2 3 4 5
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 06-12-2018 at 03:41 AM. Reason: Uploaded file
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Randomize a module with a sub of calling other subs.

    You'd need to use Application.Run since Callbyname only works with objects (modules don't count).

    Here's a simple method as you only have 5 to choose from
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: Randomize a module with a sub of calling other subs.

    xlnitwit I have 51 lol..

    so is this the method?

    Please Login or Register  to view this content.

    almost solved! lemme know and thanks all.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Randomize a module with a sub of calling other subs.

    It won’t work for that many. May I ask why you need to do this?

  7. #7
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: Randomize a module with a sub of calling other subs.

    i have a list of runners....

    and its the very same order every single day.

    So I want it to randomize instead and never have the same order of sequence.

  8. #8
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: Randomize a module with a sub of calling other subs.

    sintek's is looking promising.. trying it now for 51

  9. #9
    Registered User
    Join Date
    10-11-2003
    Posts
    81

    Re: Randomize a module with a sub of calling other subs.

    Yep did the trick sintek thanks!

    SOLVED

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,024

    Re: Randomize a module with a sub of calling other subs.

    Glad I could contribute. Tx for rep +

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Randomize a module with a sub of calling other subs.

    I'm glad it's resolved but I can't see any need for 51 different macros from your description!

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,024

    Re: Randomize a module with a sub of calling other subs.

    I was wondering the same thing...Why wanting to run so many macros...Perhaps OP can clarify and we can come up with a simplistic solution...

+ 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. [SOLVED] Help with calling subs
    By jeetkapadia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2017, 03:30 PM
  2. Getting an error when calling multiple subs from a single module
    By Blackhawks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-30-2016, 02:37 AM
  3. Multiple subs calling "Declarations" from a singular module
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-02-2014, 12:16 PM
  4. Module Subs executing Private Subs without prompt by code - Totally Lost
    By Ozan Ertem in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-26-2012, 05:31 PM
  5. Calling other subs
    By noodle48 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-30-2011, 10:56 AM
  6. Calling subs
    By fvmeul0 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2010, 05:32 AM
  7. Using Variables and calling subs
    By Brelin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-20-2008, 05:24 AM

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