+ Reply to Thread
Results 1 to 5 of 5

Conversion of Set of Rows ro Column in new sheet.

Hybrid View

apowale Conversion of Set of Rows ro... 01-10-2013, 06:45 AM
nathansav Re: Conversion of Set of Rows... 01-10-2013, 06:56 AM
apowale Re: Conversion of Set of Rows... 01-10-2013, 07:40 AM
OllieB Re: Conversion of Set of Rows... 01-10-2013, 07:28 AM
apowale Re: Conversion of Set of Rows... 01-10-2013, 07:29 AM
  1. #1
    Registered User
    Join Date
    12-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    6

    Conversion of Set of Rows ro Column in new sheet.

    Hi All,

    I am looking to copy set of rows and paste them into new sheet with "transpose" option.

    The data consist of set of 17 rows (sat a1:a17) one below the other with blank row in between.

    I need to copy paste same into another sheet with:
    A1:17 getting transposed to A1:Q1
    A19:A35 getting transposed to B1:Q1
    and so on..

    The sample data sheet is attached with desire result.
    Please advise,

    Regards,
    Amol.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Conversion of Set of Rows ro Column in new sheet.

    A good way to learn would be to do the operation using cut and paste special, recording a macro, then view the code generated.

  3. #3
    Registered User
    Join Date
    12-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Conversion of Set of Rows ro Column in new sheet.

    Hi OllieB,

    The Macro worked amazingly

    Its solved my issue. The output came contain 39753 rows..
    Many thanks

    Regards,
    Amol

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Conversion of Set of Rows ro Column in new sheet.

    The following code should do the trick without formulas

    Public Sub VBATranspose()
    '# declare
         Dim xlsSource As Excel.Worksheet
         Dim xlsTarget As Excel.Worksheet
         Dim varContents As Variant
         Dim lngSourceRow As Long
         Dim lngTargetRow As Long
         Dim lngColumn As Long
    '# initialise
         lngTargetRow = 0
         Set xlsSource = ThisWorkbook.Worksheets("Input Data")
         Set xlsTarget = ThisWorkbook.Worksheets("Desire Result")
    '# loop for areas on source worksheet
         With xlsSource
              For lngSourceRow = 1 To .Cells(.Rows.Count, "A").End(xlUp).Row Step 18
                   varContents = .Range(Cells(lngSourceRow, "A").Address, Cells(lngSourceRow + 16, "A").Address).Value
                   lngTargetRow = lngTargetRow + 1
                   For lngColumn = 1 To 17
                        xlsTarget.Cells(lngTargetRow, lngColumn).Value = varContents(lngColumn, 1)
                   Next lngColumn
              Next lngSourceRow
         End With
    End Sub
    If you like my contribution click the star icon!

  5. #5
    Registered User
    Join Date
    12-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Conversion of Set of Rows ro Column in new sheet.

    Hi Nathansav,

    The problem is sample data contains only two such sets, whereas my actual data contains 10000's of such sets.
    Also, I am unaware of how to put the things in loop.

    Regards,
    Amol

+ 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