+ Reply to Thread
Results 1 to 13 of 13

Code for copying columns One below the other

  1. #1
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Code for copying columns One below the other

    Hi,

    I have a data in excel like beow

    Column A3:J100 product details like code, desription, suplier etc and ( row 2 is header)
    from column K2 to N100 i have data for "Sales, Qty, Price,Month for Week 1 ( "1" is mentinoed in row 1 above "Sales" that is K1)

    and again from M2 to P100 i have data for "Sales, Qty, Price,Month for Week 2 ( "2" is mentinoed in row 1 above "Sales" that is M1)

    same thing for about 20-25 weeks in one sheet and i have 10 sheets like this 1 file

    whatIi have to do manually is ,
    open a new sheet,
    copy from A2:100 paste Sales, Qty, Price,Month for Week 1
    again copy A1-100 below paste Sales, Qty, Price,Month for Week 2
    again copy A1-100 below paste Sales, Qty, Price,Month for Week 3

    once we finish this go the next sheet and do the same procedure

    I have attached the excelfile with input and output


    Can you please help with a code for this

    thakns
    Arvind
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Code for copying columns One below the other

    Please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    Try this on a copy of your workbook
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Code for copying columns One below the other

    Great it works,

    but it wokrs in only one sheet, i have about 10 sheets and all the data to be pasted in output sheets

    can you help me to modify this

    thanks for your help

  5. #5
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Code for copying columns One below the other

    Hi,

    attached the file with actual data.

    can you plese help
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    You said that the previous code worked so I stuck with that workbook, just added extra sheets.
    See attached.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    This might be what you have in mind for your last attached workbook.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Code for copying columns One below the other

    Hi jollie,

    Thanks it works at 99% as per the requirement. however when its pasting the values in Column A of output sheet that is the value from Row 9 ( in the attached J9 for example ) by default it takes the seriol number, 1,2,3,4, however that can be any number if it says 12, then i need to get 12 in col A of output sheet.

    I added another sheet which started from 12, 13, 14 , for which i am getting result as 1,2,3, also can we add the sheet name in another column so that i can differenciate what sheets are used .

    Thanks for your great help
    Last edited by aravindhan_31; 11-19-2014 at 11:45 PM.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    Like this?
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Code for copying columns One below the other

    Thanks,

    it runs but gives duplicates in output sheet. attached the format with 2 sheets

    also i used replace all option to replace texts to blank in row 9 so that i t takes data only for weeks.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    Where or what are the duplicates?
    Do the last four Columns need to be copied into the Output Sheet also? (You replace the headers in Row 10 with blanks)

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Code for copying columns One below the other

    If you don't want the last four Columns, change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    I neglected to add the extra Column for the values in Row 9. Change it in the Array to something meaningful.
    Please Login or Register  to view this content.
    You have 1975 Rows per Sheet, 16 Columns per Sheet copied 4 Columns at once, 2 Sheets.
    1975 x 16/4 x 2 = 15800. You have that amount of Rows in the Output Sheet after the macro is finished.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Code for copying columns One below the other

    Thanks,

    it worked

    Thank yo so much.

    Regards
    ARvind

+ 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] Code worked (copying code to the end of a column) then only entered the top line.
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-26-2013, 03:33 AM
  2. [SOLVED] Need a macro code for matching a data and copying multiple columns
    By faizaan316 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2013, 01:40 PM
  3. [SOLVED] Code from tigeravatar ,Copying data from one sheet and copying it
    By DanielRay in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-07-2012, 03:07 PM
  4. Replies: 1
    Last Post: 11-22-2011, 02:36 PM
  5. Code for copying a code into a specific place in an outlook template?
    By VoodooChild in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-21-2010, 10:08 AM

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