+ Reply to Thread
Results 1 to 3 of 3

Building a For Next loop procedure

Hybrid View

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Building a For Next loop procedure

    I'm a little stuck here. Not sure how to build in the second loop for the destination cells.

    I am cutting from column G:N but four at a time and then pasting 4 cells on top of each other starting at A15:D15. The destination range would be row 15, 16, 17, 18 etc., but I'm not sure how to reference the loop. Any thoughts?

    Sub Macro2()
    Dim LR As Long, i As Long
    LR = Range("G" & Rows.Count).End(xlUp).Row
        For i = 2 To LR
            Range("G" & i & ":" & "J" & i).Cut Range("A15:D15")
            Range("K" & i & ":" & "N" & i).Cut Range("A16:D16")
        Next i
    End Sub

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: Building a For Next loop procedure

    Try this
    Sub Macro2()
    Dim LR As Long, i As Long, j As Long
    LR = Range("G" & Rows.Count).End(xlUp).Row
    j = 15
        For i = 2 To LR
            Range("G" & i & ":" & "J" & i).Cut Range("A" & j & ":D" & j)
            Range("K" & i & ":" & "N" & i).Cut Range ("A" & j + 1 & ":D" & j + 1)
            j = j + 2
        Next i
    End Sub

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Building a For Next loop procedure

    Perfect Thanks...

+ 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