Page 2 of 2 FirstFirst 1 2
Results 21 to 33 of 33

Thread: Need help with Question, is it possible to Call modules to work or loop through?

  1. #21
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    [mdmackillop: Post 11
    Here is a simple example. Run Test on a blank worksheet
         Dim j 
     
    Sub Test() 
        For j = 1 To 3 
            Call MasterMacro 
        Next 
    End Sub 
    '
    '
    '
    '
    '
    '
    '


    Emph added
    Please take the time to read the Forum FAQ

  2. #22
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Ok I ran it on the blank sheet and it places Zeros int F column int first 2nd and 3rd row .

    Im new at this method of callung the macros and need help on how to solve this. i dont under stand why some modules in the code have this > For i = 1 To 100000 For i = 1 To 3

  3. #23
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    ok soI placed the right under

    the Sub Test () For j=1 to 100 and i got this below


    27 27 27 27 27 27
    54 54 54 54 54 54
    81 81 81 81 81 81
    108 108 108 108 108 108
    135 135 135 135 135 135
    162 162 162 162 162 162
    189 189 189 189 189 189
    216 216 216 216 216 216
    243 243 243 243 243 243
    270 270 270 270 270 270
    297 297 297 297 297 297
    324 324 324 324 324 324
    351 351 351 351 351 351
    378 378 378 378 378 378
    405 405 405 405 405 405
    432 432 432 432 432 432
    459 459 459 459 459 459
    486 486 486 486 486 486
    513 513 513 513 513 494
    540 540 540 540 540 520
    567 567 567 567 567 546
    594 594 594 594 594 572
    is this
    showing the how many times each macro runs? this is on the blank sheet.S
    o if I get it to run on my sheet with data will this be placed over my existing data and not just run my macros ?

  4. #24
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    Implementation of the demonstration code
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #25
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    ok I watched the demonstration,

    does the count that you have in column A have to be there. when i tun the code in mibe i writes over my data

    Also when I run mine does the code wait until the first module fisnish before goin on to the next module 8? and so on down the modules. meaning does the call module go as fast as each code/ 7 takes maybe a minute to complete then 8 takes half a minute and so on until the 7 8 9 10 11 12 take a little over 2 minutes to run.



    Also you ve in you deveoper box the individual macros call macro 7 then macro 8 etc

    my macros in the box show the actual name of the macros not module 7 or module 8 etc or even Macros 7 ro macros 8 etc. im just trying to figure out why it doesnt work


    Sub Test () is module7 (code)
    Sub testA_v2() is Module8 (code)
    Sub test2 () is Module9 (code)
    Sub SplitAddress() is Module10(code)
    Sub Test_v3() is Module11 (code)
    Sub sbClearCells() is Module12 (code)

    ok so I had Change the name of the macros to macro 7 8 9 10 11 12
    I ran it and it over wrote everything in columns A though F on my sheet with Zeros

    so i ran it but the result of my codes didn't occur the only thing that happened was zeros over wrote over my data my codes use to run.




    Sub run_all_six()

    macro7
    macro8
    macro9
    macro10
    Macro11
    Macro12

    End Sub

    could this work to run macros consecutively then add code that will repeat these for 8000 times?







    Last edited by estatefinds; 08-14-2017 at 07:10 PM.

  6. #26
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    Quote Originally Posted by estatefinds View Post
    I have modules 7,8,9,10,11,12 that are Subs

    Using the Code:
     
    Sub MasterMacro()
         Call Macro7
          Call Macro8
          Call Macro9
          Call Macro10
          Call Macro11
          Call Macro12
    End Sub
    I Believe each macro would run, one at a time, one by one; The question is, is there a way to run by calling these macros to repeat to a specific amount of times before it stops.

    Any help on this is Greatrly Appreciated!!!
    Thank you in Advance,
    Sincerely

    Dennis
    Sub Test()
         For j = 1 To 3 
            Call MasterMacro 
        Next 
    End Sub
    I believe this question has been answered.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #27
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    I tried that but the only thing I get are zeros over writing my data and the macros are not carrying out the job my macros are meant to do.
    Question is why are my macros not being carried out using the call mastermacro?
    help on this is appreciated.
    Last edited by estatefinds; 08-15-2017 at 08:22 AM.

  8. #28
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,888
    Location
    Quote Originally Posted by estatefinds View Post
    I tried that but the only thing I get are zeros over writing my data and the macros are not carrying out the job my macros are meant to do.
    Question is why are my macros not being carried out using the call mastermacro?
    help on this is appreciated.
    Since no one knows what your macros are doing, I think you'll need to revise them to handle 8000 re-runs

    As Mac says, there have been many examples of how to run your set of macros multiple times

    If the ...


    Sub Test() 
        For j = 1 To 8000
            Call MasterMacro 
        Next 
    End Sub
    ... doesn't do what you want, you'll need to revise Macro7, Macro8, ...
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #29
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    No one here has a clue what you did with the above suggestions.

    Writing Code requires great precision in logic, word choice and grammar, and typing and spelling.
    Please take the time to read the Forum FAQ

  10. #30
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Thank you for your help on this!
    I appreciate everyone's help!!!
    Thank you!
    Sincerly,
    Dennis

  11. #31

  12. #32
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    I have that book,Thank you!

    I have figured out what exactly I needed,
    Sub LoopMacro()
    Dim x As integer
    For x=1 to (whatever number)
    Call (name of macro)
    Next x
    End sub

    Thank you, everyone for your input!

  13. #33
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    Exactly as you were advised in Post #6
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •