+ Reply to Thread
Results 1 to 4 of 4

VBA transpose multiple times

  1. #1
    Registered User
    Join Date
    03-16-2016
    Location
    Bergen, Norway
    MS-Off Ver
    13
    Posts
    2

    VBA transpose multiple times

    Hi,

    I am currently working on a big set of data downloaded from Morningstar Direct. I need help with a macro that can change the exported document from horizontal to vertical.

    For example:

    From:
    Ticker Data1-2000 Data1-2001 Data1-2002 ... Data1-2016 Data2-2000 Data2-2001 and so on


    To:
    Ticker Data1-2000
    Data1-2001
    ...
    Data1-2016
    Data2-2000
    Data2-2001
    ...

    Every datavariable goes from 2000 to 2016. We have more then 500 tickers that need the same transformation. Is there any VBA code that can do this for me? It will save my life (at least my Easter)!


    Many thanks in advance!!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,642

    Re: VBA transpose multiple times

    the layout of imported data as well as expected layout id not obvious. Include few tickers and some data and attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window (or use the paperclip icon if it works with your browser).
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    03-16-2016
    Location
    Bergen, Norway
    MS-Off Ver
    13
    Posts
    2

    Re: VBA transpose multiple times

    Hi Kaper,

    Thanks for the quick and informative reply. This is where i am at now:

    I have made this macro:

    Sub Flip()
    '
    ' Flip Macro
    '

    '

    Sheets("S&P 500 Constituents").Select
    Range("I2:X2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("D2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Sheets("S&P 500 Constituents").Select
    Range("AB2:AQ2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Sheets("S&P 500 Constituents").Select
    Range("AR2:BG2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("F2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Sheets("S&P 500 Constituents").Select
    Range("BH2:BW2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("G2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Sheets("S&P 500 Constituents").Select
    Range("BX2:CM2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("H2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True

    End Sub


    As you can see everything is taken from row 2 in my S&P500 sheet, and then transposed into sheet1.

    How can i make this macro repeat the same operation on row 3, 4, 5 ... 518?


    Thank you very much for the reply!

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,642

    Re: VBA transpose multiple times

    As opposite to what you shown above, you now copy several 16cells wide ranges to set of cells located in one row (not in one column).


    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window (or use the paperclip icon).




    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

+ 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. Transpose multiple columns with multiple rows into one column
    By trizzle2131 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-22-2015, 12:28 PM
  2. Replies: 2
    Last Post: 12-09-2013, 05:34 AM
  3. If a search term can be found 1 time, 2 times 3 times 4 times 5 times
    By excelcandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 09:57 PM
  4. Replies: 4
    Last Post: 03-08-2013, 09:49 AM
  5. How to transpose multiple columns into multiple rows?
    By alexxgalaxy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-15-2013, 10:12 AM
  6. Transpose multiple rows to multiple columns
    By a020ata in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-06-2013, 05:21 AM
  7. [SOLVED] How to transpose non-uniform data in multiple columns into multiple rows?
    By alexxgalaxy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-03-2013, 08:40 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