+ Reply to Thread
Results 1 to 6 of 6

Help with a macro formula to convert horizontal data into veritical data

  1. #1
    Registered User
    Join Date
    04-26-2013
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    4

    Help with a macro formula to convert horizontal data into veritical data

    I have spreadsheet which has a cost center listed going down vertical and for each cost center this is potentially 35+ project numbers which has budget info that run horizontally on the spreadsheet.

    Is there a formual or a macro I can use so that I can move the horizontal column headings to line up veritcally with their respective cost center?

    Any help or suggestions would be greatly appreciated!

    Attached (if I uploaded this correctly) shows the current lay out and the desired lay out I need.

    Book1.xlsx

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help with a macro formula to convert horizontal data into veritical data

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    04-26-2013
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Help with a macro formula to convert horizontal data into veritical data

    This is only capturing the 2nd cost center (i.e. ABC56789). It is giving me the 3 columns of data I need, but it is not picking up the first cost center.

    Also -- will this work if say I have 40+ cost centers going vertical and 40+ project numbers running horizontal?

    For this example, I only pulled 2 cc and 7 project nubmers? How can the code be modified to caputure a larger number of each?

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help with a macro formula to convert horizontal data into veritical data

    Did you run the macro on the sample file which you uploaded?

    I ran it on the same file and it worked fine. The header is in row 2 and data starts in row 3.

    The macro will take care of as many projects and cost centers are there. You do not need to change anything.

  5. #5
    Registered User
    Join Date
    04-26-2013
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Help with a macro formula to convert horizontal data into veritical data

    OK ... so I re-ran in on the file I posted. I had to include a blank row so that the title cost center appears in A2. It worked fine.

    Then I ran it on an actual file I have where there are 163 cost centers listed vertically and 43 project numbers horizontally and it worked -- only up to a point. It cut off the last project on every cost center and also left of 30 cost centers all together.

    Thoughts?

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

    Re: Help with a macro formula to convert horizontal data into veritical data

    As an options. Output in new sheet
    Attached Files Attached Files

+ 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