Results 1 to 4 of 4

For Loop to move Rows(B:D) Data to Single Column Consecutively. Code not working.

Threaded View

  1. #1
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    For Loop to move Rows(B:D) Data to Single Column Consecutively. Code not working.

    Hello,
    This code has me all sorts of frustrated. It seems like it should work to me but it's not.

    So what I want to accomplish is to move data from the mod sheet to the Final Sheet. Specifically, Columns (B:D) data on each populated row in the mod sheet. So for example, currently, the value in mod sheet B2 should move to the Final Sheet A2, the value in mod sheet C2 should move to the Final Sheet A3, and the value in mod sheet D2 should move to the Final Sheet A4, Then it should move to mod sheet row 3 and repeat and on and on.
    My code is posted below, Any help is greatly appreciated!

    Private Sub cb_Click()
    Dim MyCell As Variant, modLR As Integer, FinalLR As Integer, MyRange As Range
    On Error Resume Next
    ActiveWorkbook.Names("MyRange").Delete
    On Error GoTo 0
    modLR = Sheets("mod").Range("A" & Rows.Count).End(xlUp).Row
    FinalLR = Sheets("Final").Range("A" & Rows.Count).End(xlUp).Row + 1
    Sheets("mod").Range("$A$2:$A" & modLR).Name = "MyRange"
    For Each MyCell In Sheets("mod").Range("MyRange")
    Sheets("Final").Range("$A$2:$A$" & FinalLR).Value = MyCell.Offset(0, 1).Value
    Sheets("Final").Range("$A$2:$A$" & FinalLR + 1).Value = MyCell.Offset(0, 2).Value
    Sheets("Final").Range("$A$2:$A$" & FinalLR + 2).Value = MyCell.Offset(0, 3).Value
    FinalLR = FinalLR + 2
    Next MyCell
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy each row consecutively into one single column preserving formulas
    By KennyUK in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 08-09-2015, 09:42 PM
  2. [SOLVED] Macros To Move Multiple Rows To Another Sheet And Macro To Move Single Rows To DAX Table
    By jcaynes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2013, 05:08 PM
  3. Need VBA Code To Combile Data from Different Columns to Single Column for multiple rows
    By p.swaroopr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2013, 09:20 AM
  4. Selection of loop data, move copy and paste data, and exclude blank rows
    By mav02004 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 10:20 AM
  5. How do i move like data in columns to single rows?
    By ncsisz in forum Excel General
    Replies: 3
    Last Post: 07-23-2012, 12:09 PM
  6. Code not working - move rows when cell is less than zero
    By wishmaker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2011, 10:40 AM
  7. Loop though rows and move data
    By Wraithxiv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2011, 11:14 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