+ Reply to Thread
Results 1 to 12 of 12

Extract data from one xls file to another

  1. #1
    Registered User
    Join Date
    12-18-2008
    Location
    Illinois
    Posts
    7

    Extract data from one xls file to another

    Good Morning,
    I have a report that is downloaded off a company database and creates a report that is attached.
    Is there a way to create a macro to extract some data that I need and leave the rest:

    I need to keep and everything in the assigned column
    PB ID (A3), Issue (B3), Group Code (J3), Group Name (K3), Sub group id (L3), Sub Group Name (M3),Subject ID (L3), Subject Group Name (M3), Subject ID (N3), Subject (O3), PB Status (P3), CPM Report Name (T3), CPM Profile Name (U3), Profile State (V3).

    The worksheet's name changes so I can't reference the worksheet. Attached is a copy of what I get when downloaded.

    Your help is greatly appreciated.
    Attached Files Attached Files
    Last edited by jguilfoyle; 04-13-2009 at 10:59 AM.

  2. #2
    Registered User
    Join Date
    12-18-2008
    Location
    Illinois
    Posts
    7

    Re: Extract data from one xls file to another

    I've done some work but am a beginner to say the least. I have this code doing some of the things I want but I really need it too gather the data from the columns vice rows.
    Can anyone help. The sheet labeled 4425 is what I need it too look like but I need to gather the information in the columns.
    Thanks
    John
    Here is the code to date.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Extract data from one xls file to another

    Create an XLS, update an MDB or edit the existing XLS? If the latter, then maybe you can post XLS with the columns removed or added based on your example.

    You referenced some columns twice but gave conflicting Column names. e.g. Sub Group id (L3), Subject ID (L3).

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Extract data from one xls file to another

    jguilfoyle,

    See the attached workbook "Remove Columns from a daily report - sRPT_1239627017(1) - jguilfoyle - SDG.xls" with macro "NewReport".

    The macro will create a new sheet, copy the data, then uses an array to remove the unwanted columns.

    Run the macro from sheet "RPT_1239627017". It will create a new sheet "New_RPT_1239627017".


    Have a great day,
    Stan
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  5. #5
    Registered User
    Join Date
    12-18-2008
    Location
    Illinois
    Posts
    7

    Re: Extract data from one xls file to another

    I am attaching 2 xls files:
    RPT_1239643022.xls is the file as I receive from our database

    Fields needed.xls - this is what I need to code to show mining the data from teh appropriate fiels from the original sheet above.

    I really appreciate any help you or anyone can offer.
    Thanks
    John
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-18-2008
    Location
    Illinois
    Posts
    7

    Re: Extract data from one xls file to another

    Stanley
    Thanks, it does what I need it too. However, I can't seem to save teh macro into xls. Is there a way to do taht? I don't have much experience doing this with xls. When I wrote a macro in word I saved it with no problem, but can't seem to do that with this one in xls.

    The reason I ask is I will be using this for a number of different xls sheets and would hate to have to copy and paste the macro each time.
    Thanks
    John

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Extract data from one xls file to another

    John,

    You could copy the "NewReport" macro, into your PERSONAL.XLS file, into a Module.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).



    Press and hold down the 'ALT' key, and press the 'F11' key.

    On the left side of the display, click on the "+" box for "VBAProject (PERSONAL.XLS)"

    On the 'Insert' menu, click 'Module'.

    Copy the below code, and paste it into the Module (on the right pane).


    Please Login or Register  to view this content.

    Then you culd run macro "NewReport" from PERSONAL.XLS, against the worksheet "RPT_#########" that is active.


    Have a great day,
    Stan

  8. #8
    Registered User
    Join Date
    12-18-2008
    Location
    Illinois
    Posts
    7

    Re: Extract data from one xls file to another

    Thanks, it works like a charm. Appreciate your help.
    John
    Last edited by jguilfoyle; 04-14-2009 at 08:41 AM. Reason: Solved

  9. #9
    Registered User
    Join Date
    06-25-2009
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract data from one xls file to another

    Hi,

    I am trying to modify the macro to suit my workbook and I can't seem to adjust the code. I have attached the way an export looks (column headings) and then the second tab show the order I need to have them come out following the macro. Any assistance appreciated.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Extract data from one xls file to another

    spearo99,

    See the attached workbook "Array - delete unwanted columns - reorder columns - Macro Fields(1) - spearo99 - SDG10.xls" with a new "NewReport" macro.

    With sheet "WS" as the active sheet, run the "NewReport" macro.

  11. #11
    Registered User
    Join Date
    06-25-2009
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract data from one xls file to another

    Hi Stanley,

    Thanks for the above, the only thing is when I run the macro there is a gap in the file with the column heading sub group not appearing. Not sure why as it is listed in the array?
    Last edited by spearo99; 06-26-2009 at 03:54 AM. Reason: Spelling!

  12. #12
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Extract data from one xls file to another

    spearo99,

    I had in the array, "Sub Group()". It should have been "Sub Group".

    And, I added some code, that if a title was not found in row 1 or your data set, that all the correct titles would be in the new worksheet.

    See the attached workbook "Array - delete unwanted columns - reorder columns - Macro Fields(1) - spearo99 - SDG10.xls" with the updated "NewReport" macro.

    With sheet "WS" as the active sheet, run the "NewReport" macro.


    How much time do you think my macro will save you in hours per day/week/month?
    Last edited by stanleydgromjr; 06-26-2009 at 08:00 AM.

+ 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