+ Reply to Thread
Results 1 to 12 of 12

Transpose in chunks with vba

  1. #1
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Transpose in chunks with vba

    I have 135,000 cells that need to be transposed which is too large to use the paste special transpose or the transpose array. The range does fit within excels row and column limits but excel just can't handle that many cells at once. Is there vba that would allow me to take the entire selection and transpose itin pieces? Or is there another way to approach this?
    Edit: I should add that I can transpose a row or column at a time but I would need to do that 8000 times.
    Last edited by JPfowl; 08-14-2013 at 11:50 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    If you are transposing from rows to columns, the limit is 16384

    Attach a sample, including a desired result. To attach, go to advance then attachment.

  3. #3
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Transpose in chunks with vba

    I can't attach a sample as the document I am working on has sensitive information.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    We do not need your actual data. We need a sample of the layout and format of your data. Remove any confidential information. It needs to mimic your actual data. With out a sample, I can not see how the layout of the sheet. I can not test it either.
    The choice is yours.

  5. #5
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Transpose in chunks with vba

    This doc contains a sample of smaller size. My actual data has 2171 rows and 628 columns. I was thinking I could transpose by taking a row or column at a time and transposing that. Conceptually you would take a count of the rows, transpose the first row to column, increase your transpose varible and repeat until the transpose varible reaches the count of rows. I just don't have enough experience to create the code for this. test.xlsx

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    The code works on the on the sample, and need to test it on actual data. The result is in new sheet.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Transpose in chunks with vba

    Rather than turning the sensitive data into junk letters, I just ran the macro. It works. Here's the macro for anyone else that wants to use it (credit goes to AB33):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    JPfowl,
    You are welcome!
    Please mark this thread as solved!

  9. #9
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Transpose in chunks with vba

    Today I tried the code again and it failed because "subscript was out of range". If I understand the code correctly then the sheet name is not correct. Is there a way to change the code to a more generic selection (using the actively selected cells rather than a fixed sheet)? Also does it matter if I am using r1c1 instead of the "normal" cell reference nomenclature?

    test.zip

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    I have tried the code on the attached and it works. Here is an amended code. This code works with any sheet name, but the cursor has to be on the active sheet, i.e. where the source sheet when you run the code.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-14-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Transpose in chunks with vba

    Do you know how large of a range that this can handle?

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Transpose in chunks with vba

    Over 1m rows and 16384 columns.

+ 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. [SOLVED] Concatenate a column of texts into chunks of 10 with VBA
    By annabellesays in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2013, 10:11 PM
  2. Chunks of Macro being skipped when running
    By BehrBrew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2012, 01:01 PM
  3. pasting together chunks of data sequentially
    By m121212 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2010, 03:11 PM
  4. copying chunks of data together
    By m121212 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2010, 12:19 PM
  5. [SOLVED] Getting chunks of 200 items for stock query
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2005, 02:06 PM

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