+ Reply to Thread
Results 1 to 6 of 6

How to copy Non adjacent columns from many worksheets

  1. #1
    Registered User
    Join Date
    07-29-2009
    Location
    Newport, Wales
    MS-Off Ver
    Excel 2007
    Posts
    3

    How to copy Non adjacent columns from many worksheets

    Good Day,

    I am putting out a request for some help?

    I have a folder called PRMResults. It contains test records in .csv, a lot of them!! The test records are named after the serial number of the tested unit. Each record has 10 columns of data starting from the second row down, the first being the headings for each column.

    I would like to copy only the contents of columns B, D, E and G from each work sheet in the folder and paste into a new workbook. Could someone provide a script that could do this.

    Thanks

  2. #2
    Registered User
    Join Date
    11-11-2008
    Location
    Syracuse NY
    MS-Off Ver
    2007
    Posts
    90

    Re: How to copy Non adjacent columns from many worksheets

    It would take me too long to figure out the parts involving dealing with .csv's, dealing with multiple files, and the rest. You could make this easier by opening each of the csv's, saving them as .xls or .xlsx files, then running the macro on each of them. If you can do that, this is most of what you need. You will have to do a little research and modify it a bit.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: How to copy Non adjacent columns from many worksheets

    Hi
    Save the attached file inside the folder containing CSV files and run the macro
    Ravi
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-29-2009
    Location
    Newport, Wales
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to copy Non adjacent columns from many worksheets

    Hi,

    Ravi - Thanks for the script but I seem to have a problem. When I run the macro (from saved within the folder containing my files) all that copies is the file name into column A and this line comes up as an error:
    y = Workbooks("PQ.xls").Worksheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row
    And this is the formula box for cell B1 =LEFT(A1,FIND("[",A1)-1)
    it also opens up the first file in the folder.

    I am using office 2007 if that makes a difference. I have noted that when I save the xls files with the marco enabled the file name becomes xlsm. I changed all the xls to xlsm but it did the same thing.

    Sorry to be a pain

  5. #5
    Registered User
    Join Date
    07-29-2009
    Location
    Newport, Wales
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to copy Non adjacent columns from many worksheets

    Jrussell - Sorry for the late reply, head in the clouds today. Thanks for your peice of script. I am having a go at playing with it.

    Have a good day

  6. #6
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: How to copy Non adjacent columns from many worksheets

    Hi
    You have mentioned the records as csv files. It has worked with a test sample at my end. Try the modified macro from attached file.
    Ravi
    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)

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