+ Reply to Thread
Results 1 to 7 of 7

SOLVED Help to VBA loop

  1. #1
    Registered User
    Join Date
    05-13-2021
    Location
    Sweden
    MS-Off Ver
    10
    Posts
    4

    SOLVED Help to VBA loop

    Hey guys!

    I have the following VBA code:

    Sub TEST()
    For Iteration = 1 To Cells(15, 16)
    Cells(10 + Iteration, 13) = Cells(4, 18)
    Cells(10 + Iteration, 12) = Iteration
    Next Iteration

    End Sub


    I want to repeat this sub code 1000 times and store the value in a different cell. How do I code this loop?

    Looking forward to your replies!

    /Monfrizo
    Last edited by Monfrizo; 05-15-2021 at 10:35 AM. Reason: SOLVED

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    796

    Re: Help to VBA loop

    if you can provide a sample file with some sample data or at least how you expect to see the results, that would help other assist.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  3. #3
    Registered User
    Join Date
    05-13-2021
    Location
    Sweden
    MS-Off Ver
    10
    Posts
    4

    Re: Help to VBA loop

    Here you go!

    Thanks!
    Attached Files Attached Files
    Last edited by Monfrizo; 05-14-2021 at 01:07 PM.

  4. #4
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,420

    Re: Help to VBA loop

    We still need to understand where you want to see your results and what you mean by a different cell

    Are you saying that you want the second outputs of 50 results starting in BM 23, then the next in BN..etc.

    In which case jus wrap your loop in another loop 1 to 50 loop and use that loop index to move across columns.e.g.


    Please Login or Register  to view this content.
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    05-13-2021
    Location
    Sweden
    MS-Off Ver
    10
    Posts
    4

    Re: Help to VBA loop

    Thanks for a quick answer!!

    When I perform 1 simulation from pressing the button (from the Excel sheet) It currently calculates the Cell BN9 50 times and place each result in BK23 +1 until 50 iterations is done.

    Subsequently to the 50 calculations I calculate an average output (Cell BK14) and standard error (Cell BK15) on the 50 outputs.

    I then want to copy cell BK14 and BK15 to Cell BR23 and Cell BS23.

    I want to loop the process above above and copy the next output from Cell BK14 and BK 15 to cell BR24 and BS 24, and onwards until I fill out cell BR23:BR122 and cell BS:23:BS122.


    /Kasper

  6. #6
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,420

    Re: Help to VBA loop

    In that case just add an instruction to update the results table

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-13-2021
    Location
    Sweden
    MS-Off Ver
    10
    Posts
    4

    Re: Help to VBA loop

    Hi Richard,

    Exactly what I was looking for! Thank you very much for the kind and fast help! I appreciate it!!!!

+ 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. Loop through emails to find Email today, if not found loop Date -1
    By lougs7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2020, 12:48 PM
  2. [SOLVED] VBA to loop through cell-defined range and paste table output after each loop.
    By mscott123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-18-2019, 03:41 AM
  3. Replies: 13
    Last Post: 07-08-2018, 05:22 AM
  4. [SOLVED] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  5. [SOLVED] Auto email loop with formatted table data breaking on second loop VBA
    By Who_else in forum Excel General
    Replies: 6
    Last Post: 03-24-2016, 06:22 AM
  6. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  7. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM

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