+ Reply to Thread
Results 1 to 2 of 2

Copy rows to another sheet with transpose

Hybrid View

excelios Copy rows to another sheet... 02-11-2010, 03:03 PM
StephenR Re: Copy rows to another... 02-11-2010, 03:10 PM
  1. #1
    Registered User
    Join Date
    02-11-2010
    Location
    lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    1

    Copy rows to another sheet with transpose

    Hi,

    with the macro below I am able to copy and paste rows from sheet1 to sheet 2 into column A and B. But if you read the code you can see that I specified:

    ActiveCell.Offset(35, 0).Select for sheet2

    This is to allow me to copy /paste each row from sheet 1 into sheet 2 every 35 times. Every row in sheet 1 has 35 cells.

    What I am trying to achieve here is that I don’t need to use ActiveCell.Offset(35, 0).Select .... but instead the macro is able to recognize that when copy paste for 1 row finishes in column A or B it keeps copying the remaining rows from sheet 1 to sheet 2 exactly a row below where the last paste finished.

    Thanks in advance

    Sub Test()
     
        Sheets("Sheet2").Select
        Columns("A:B").Select
        Selection.ClearContents
            Sheets("Sheet1").Select
        Range("B3").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("B1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
        Range("B1").Select
        For Each Row In Sheets("Sheet1").Range("A1:A40").Cells
            Sheets("Sheet1").Select
            'Range("B1").Select
            ActiveCell.Offset(1, 0).Select
            If ActiveCell.Offset(0, -1) <> 0 Then
             Range(Selection, Selection.End(xlToRight)).Select
             Selection.Copy
             Sheets("Sheet2").Select
             ActiveCell.Offset(35, 0).Select
                 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
                 False, Transpose:=True
     
            End If
        Next
     
        Sheets("Sheet1").Select
        Range("B1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
        Range("A1").Select
        For Each Row In Sheets("Sheet1").Range("A1:A40").Cells
            Sheets("Sheet2").Select
            ActiveCell.Offset(35, 0).Select
            If ActiveCell.Offset(0, 1) <> 0 Then
             Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
                 False, Transpose:=True
     
            Else: End
            End If
        Next
    End Sub

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copy rows to another sheet with transpose

    Can you attach a sample workbook? Not sure I follow that.

+ 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