+ Reply to Thread
Results 1 to 5 of 5

Change a table (col to rows and vice versa)

  1. #1
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Change a table (col to rows and vice versa)

    Hi,

    I have a table showing products per location. I have locations in col A and products in col B.

    I would like a macro to change the format of a table in the way that columns becomes rows and rows becomes columns - in a way...
    The location should be stated in Row A and the products in the rows below (same column).

    Please look at the attached example.

    The tabel change every month - new locations are added as well as new products are added to existing locations.

    Thanks for your help!
    //Martin
    Attached Files Attached Files
    Last edited by masben; 07-29-2013 at 06:32 AM.

  2. #2
    Registered User
    Join Date
    06-22-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Change a table (col to rows and vice versa)

    Martin,

    The attached has a macro that runs when you press the button.

    The code is below. It will automatically select all relevant data in columns A and B so no matter how many rows you have it should work. The top left hand output cell is set in the code which you can change.

    Please Login or Register  to view this content.
    Any questions let me know.

    Regards

    David
    Last edited by JBeaucaire; 08-14-2013 at 10:30 AM.

  3. #3
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Change a table (col to rows and vice versa)

    David! Many thanks!

    Your macro does exactley what I wanted :-)

    With one exception... (but I forgott to mention it in my problem description so - my fault..)
    If there has been no sell of any product at a certain depot (i.e. all cells in the B column is blank for that location) the macro stops at the previous location but I would like the 'empty' location as well as the following locations to be included. Se the attchment.
    Do you think it's possible?

    Thanks again,
    Martin
    Last edited by JBeaucaire; 08-14-2013 at 10:30 AM.

  4. #4
    Registered User
    Join Date
    06-22-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Change a table (col to rows and vice versa)

    Martin,

    In this version of the worksheet you need to select the table range before pressing the button, it works as you want, all I did was comment out the 3 lines of code that selected the data range.

    Excel needs to know where you data is, in the first version it did this automatically assuming that all cells in column B were filled in. In this one you select the range before you press the button to run the macro. The third possibility would be for the user to put the range in a cell or named range that would need to be updated.

    Regards

    David
    Last edited by JBeaucaire; 08-14-2013 at 10:29 AM.

  5. #5
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Change a table (col to rows and vice versa)

    Thanks again David!!

    This version suites all my needs. Awsome!

    Reputation added with pleseure :-)

    All the best,
    Martin
    Last edited by JBeaucaire; 08-14-2013 at 10:30 AM.

+ 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. Change month into day and vice versa
    By aman1234 in forum Excel General
    Replies: 6
    Last Post: 09-14-2017, 03:50 PM
  2. Nesting VLOOKUP in IF/vice versa & Pivot Table
    By jbritt609 in forum Excel General
    Replies: 10
    Last Post: 06-09-2009, 09:15 AM
  3. [SOLVED] I want columns of worksheet to become rows and vice-versa.
    By Swapping rows and columns in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-10-2006, 01:10 AM
  4. Transposing Values from Columns into Rows, and Vice Versa
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-28-2005, 11:36 AM
  5. [SOLVED] How do I change rows content to column & vice versa Excel spread s
    By Harinath in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-13-2005, 06: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