+ Reply to Thread
Results 1 to 8 of 8

Dynamically Transposing and Deleting Rows to Columns

  1. #1
    Registered User
    Join Date
    09-18-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    5

    Post Dynamically Transposing and Deleting Rows to Columns

    Hello,

    I'm really new to the world of VBA, and would appreciate some help. I have data that needs to be transposed from rows to columns within the same spreadsheet.(the rows that are transposed can then be deleted. ) The ranges would need to be set dynamically because the number of rows will vary, but each row is associated with unique id in row E - that's repeated, except for the header row. Only 4 columns will actually need to be repeated, and each inserted group of 4 (how many groups of 4 will depend on row count for each unique id in column E). These groups will need to be inserted BEFORE the last 3 columns.

    I spent a lot of time trying to wrap my head around this, and just not getting anywhere. Please help!
    Last edited by newB55; 09-22-2016 at 10:09 AM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Dynamically Transposing and Deleting Rows to Columns

    Best to upload an excel workbook, hard to work with pictures. Of course if data is sensitive replace with mock up data
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    09-18-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    5

    Re: Dynamically Transposing and Deleting Rows to Columns

    Thanks Mike7952. Here is the excel workbook.

    Also including some code that I was working on, but its resulting in errors at the moment I think I just need serious help on how to:

    1. InputRng that is comprised of selected columns - not all of the columns E though S - i really need column E, P, Q, R S.
    2. OutRng that would be column before the last 3 columns
    3. How keep iterating (while unique id in column E is the same) and transposing the associated rows for columns P - S only . (except for that 1st repeating group for each unique id, which is already transposed technically )
    4. How to also ensure the header row for the P-S should also be repeating.
    5. How to delete those repeating rows after transposing


    Please Login or Register  to view this content.
    'this is not working since i don't want all of the columns between E and S..just some
    Set InputRng = Range("E1", Range("S1").End(xlDown))

    ' not working either...but it should be inserting it before Column T
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by vlady; 09-20-2016 at 09:23 PM. Reason: Use code tags

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Dynamically Transposing and Deleting Rows to Columns

    Give this a try

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-18-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    5

    Re: Dynamically Transposing and Deleting Rows to Columns

    This is great! This was so hard for me. Here some things that need tweaking...

    1. If I try to have one unique id with say 8 rows... the the last 3 rows somehow end up in the middle and not at end. They need to always be last, and i will never know what the count would be ...4, 8, 10. (example: See "new input tab" for unique id 1114, and see the output in "sheet1" - AF, AG, AH should always be at the end of each row the last 3 columns.)

    2. Is it possible to have the the header row remain intact plus the columns should keep repeating for P, Q, R, S , like in "sample" tab - Header p Header q Header r Header s Header p Header q Header r Header s. Can all the cells also keep their original formatting?

    3. Some of the cells (in "new input" tab in red) have formulas, so when i ran the macro, they no longer worked. (T2, U2, V2 & T10, U10, V10 and T12, U12, V12). Any way to automate that as well so it carries over the formula given the new row vs column structure)
    Attached Files Attached Files

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Dynamically Transposing and Deleting Rows to Columns

    Will have to look at tomorrow I'm at work now for 12 hours.

    Thanks Mike

  7. #7
    Registered User
    Join Date
    09-18-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    5

    Re: Dynamically Transposing and Deleting Rows to Columns

    Thanks mike7952!!!! I appreciate your help.

  8. #8
    Registered User
    Join Date
    09-18-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    5

    Re: Dynamically Transposing and Deleting Rows to Columns

    Hi mike7952. I tried to fix the function but getting stuck on the portion below. It looks like when the 1st column contains duplicates (which could happen) then the last 3 columns (20, 21, 22) of the row with duplicate, get repeated and don't reflect the actual values in 20, 21, 22 for that row. Also, how can I dynamically set the column destination (right now is its 32) - i just want the destination column (for 20, 21, 22 ) to be the next cell in that row, after last 4 column grouping.

    Also, how to do I get the header row to also repeat but only for P through S. Thanks


    For Each w In .Items
    Cells(iCounter, 1).Resize(, UBound(w) + 1) = w
    With WorksheetFunction
    'w(0)
    iRow = .Match(w(0), .Index(arr, 0, 1), 0)
    '32
    ' last 3 summary columns
    Cells(iCounter, 32).Resize(, 3).Value = Array(arr(iRow, 20), arr(iRow, 21), arr(iRow, 22))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help transposing rows into columns
    By mckeven in forum Excel General
    Replies: 4
    Last Post: 10-08-2014, 04:41 PM
  2. [SOLVED] Transposing 2 - 70,000+ long columns into approx 4600 rows with 15 columns each
    By Glennstapo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 09:51 AM
  3. [SOLVED] Need help with transposing columns to rows
    By cheryl_granieri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2013, 09:14 AM
  4. macro help for transposing data and deleting rows
    By Winky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-21-2012, 01:03 PM
  5. Replies: 8
    Last Post: 11-02-2011, 02:45 PM
  6. Transposing columns to rows
    By sunitagadapu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2009, 08:54 AM
  7. Transposing columns and rows
    By TEB2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2005, 01:06 PM

Tags for this Thread

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