Results 1 to 6 of 6

Nested Loops

Threaded View

Walter12 Nested Loops 10-05-2012, 09:03 AM
Pete_UK Re: Nested Loops 10-05-2012, 09:26 AM
Walter12 Re: Nested Loops 10-05-2012, 09:46 AM
Pete_UK Re: Nested Loops 10-05-2012, 09:52 AM
Walter12 Re: Nested Loops 10-05-2012, 10:18 AM
Walter12 Re: Nested Loops 10-06-2012, 07:29 AM
  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Nested Loops

    Hi all,

    I'm struggling with nesting a loop. I have a series of calculations that loops 5 times and offsets a row each time. I then want to repeat this series of loops X amount of times. The code below is only performing the whole task on one row and not the 5 I need.

    Dim row As Long
    
    Sub multiple_calc()
    Dim theCell As Range
    Dim iMyNumber As Integer
    Dim iMyNumber2 As Integer
    
        
        Do
         iMyNumber2 = 1 + iMyNumber2
         
        
        Do
       row = row + 1
         Set theCell = Sheets("Sheet1").Cells(row + 1, "G")
            With theCell
             
            .FormulaR1C1 = theCell.Value + 5
            .Calculate
             .Offset(0, 1).FormulaR1C1 = theCell.Value + 3
             
            .Calculate
            .Offset(0, 2).FormulaR1C1 = theCell.Value + 1
            .Calculate
            
            End With
            iMyNumber = 1 + iMyNumber
        Loop While iMyNumber < 5
        row = 1
        
        Loop While iMyNumber2 < 8
        
    End Sub
    Last edited by Walter12; 10-05-2012 at 09:06 AM.

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