+ Reply to Thread
Results 1 to 15 of 15

How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

  1. #1
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Question How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Hi ,
    i have an excel file which contains 100+ records in sheet 1.
    i have to convert the specified columns to the rows of another sheet.

    My sample data is given below

    Column 1 Column 2 Column 3 Column 4 Column 5
    Name1 A 1 Yellow Yes
    Name1 B 2 Red Yes
    Name2 C 3 Blue No
    Name3 D 4 White Yes
    Name3 E 5 Pink Yes

    and after the macros done its action the sheet 2 should look like this

    Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
    Name1 A 1 B 2 Yes
    Name2 C 3 No
    Name3 D 4 E 5 Yes


    Can anyone help me out..
    Last edited by Rintil007; 05-21-2013 at 04:16 AM. Reason: Typing Mistake

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

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Column 5 sheet2, was meant to be 2,not 1 as you have 5 for name 3?

  3. #3
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Thank you for mentioning that.
    and now its rectified..

  4. #4
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Unhappy Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Anyone have any idea on the above :-(
    i'm totally confused..
    Please help me...

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Try this:-
    Your Data :- Sheet 1
    Results :- Sheet 2.
    Please Login or Register  to view this content.
    Regards Mick

  6. #6
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Thank you Mick.
    I'll try this with modification and let you know my result :-)

    thank u once again for your time and reply

  7. #7
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Thank you mick and
    There is one problem.
    Your solution is working fine with the sample i've given.
    now the problem is this.
    I'm having more than 5 rows for "Name 1" but your code is taking the first value and the last value.
    Where should i correct the macro.

  8. #8
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Hi mick
    i've made some changes to the Code but it gives me repeated values on the cells.

    Code with changes.
    Please Login or Register  to view this content.

  9. #9
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Try this:-
    The code will display the data for each unique Name in a seperate line.
    Please Login or Register  to view this content.
    Regards Mick

  10. #10
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Thank you Mick it works perfect..... :-)
    thank you very much

  11. #11
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Your welcome

  12. #12
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Mick..
    i do have one more doubt..
    I want to copy and paste the last two cells of each rows till the longest row ends...

    Then this will look like

    Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
    Name1 A 1 B 2 Yes
    Name2 C 3 No
    Name3 D 4 E 5 Yes

    this

    Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
    Name1 A 1 B 2 Yes
    Name2 C 3 C 3 No
    Name3 D 4 E 5 Yes


    any idea ???
    please help me

  13. #13
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    What happens when you have say, 6 columns in the first row and 4 in the second leaving 2 blank cells in the row to fill with the previous 4, or some similar scenario, or do you jsut want the last 2 in any row with blanks, to fill the remaining cells.

  14. #14
    Registered User
    Join Date
    05-18-2013
    Location
    Chennai,India
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    The second choice Just want to fill the last 2 of each row with blanks, to fill the remain.
    but the correspondent rows only . last two of 4th row is copied in 4th row and 5th row is copied in fifth row... hope u got me... :-)
    thank you very much for your help... :-)

  15. #15
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How to Convert Columns of Sheet 1 to Rows of Sheet 2 using Macros

    Try this:-
    If not what you want, please post more detailed example.
    Please Login or Register  to view this content.
    Regards Mick

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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