+ Reply to Thread
Results 1 to 6 of 6

VBA to Merge Multiple Excel Files - But only output 2 columns by name

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    Cary, NC
    MS-Off Ver
    gachua
    Posts
    8

    VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Hello,

    Has been a while since I posted for some help.

    I have multiple excel files with a ton of columns. I want to merge the multiple files into one spreadsheet, but only output the two columns I need.

    - One of the columns has a fixed name across ALL the excel files: (PDH-CSV)
    - The other column has a part of the name that is the same across all the excel files: TCP\Curr Estab
    - The actual name on one of the spreadsheets is \\178.215.141.36\TCP\Curr Estab => I want to key off of TCP\Curr Estab

    I have attached 2 sample files that need to be merged. I removed the majority of the columns, but left the problem/condition I am running into w/ the below script; The column I need is not always in the same place.

    1. Sample File 1 (Col A - Col E).xlsx ==> Need Column A and Column E
    2. Sample File 2 (Col A - Col G).xlsx ==> Need Column A and Column G

    Final output would be:

    || Column A || Column B ||
    || (PDH-CSV) || TCP\Curr Estab ||
    || ?????????? || ?????????????? ||
    || ?????????? || ?????????????? ||
    || ?????????? || ?????????????? ||
    || ?????????? || ?????????????? ||
    || ?????????? || ?????????????? ||

    The below script works OK, but it pulls in all the columns and the TCP\Curr Estab column is not always in the same place like the two sample files I attached so I get 'incorrect' values in the resulting output.

    Please Login or Register  to view this content.
    Thanks Again !!
    Last edited by gachua1978; 02-11-2014 at 12:10 AM.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Hi, as per forum rules, you need to use
    Please Login or Register  to view this content.
    [/noparse]
    多么想要告诉你 我好喜欢你

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Do you only need the 2 specific columns to be shown? i.e. the rest of the data is not important, and will not be copied/merged.
    And where should it be shown? In a new workbook? or in active workbook but in a new worksheet? or somewhere in the active worksheet?

    - The actual name on one of the spreadsheets is \\178.215.141.36\TCP\Curr Estab => I want to key off of TCP\Curr Estab
    What do you mean by this?

  4. #4
    Registered User
    Join Date
    09-28-2012
    Location
    Cary, NC
    MS-Off Ver
    gachua
    Posts
    8

    Re: VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Hi Millz.

    I want to run the macro in a new excel file/workbook. The only data that is important is from the columns named (PDH-CSV) which is always Column A and the column that has the partial name of 'TCP\Curr Estab'. This other column will have different names and will sometimes be in different columns (i.e. E vs. G in the two sample files). The only consistent part of that column header is 'TCP\Curr Estab'.

    Thank You and apologies for the confusion.

  5. #5
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Try this macro, you can run it anywhere, a new workbook will be created

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-28-2012
    Location
    Cary, NC
    MS-Off Ver
    gachua
    Posts
    8

    Re: VBA to Merge Multiple Excel Files - But only output 2 columns by name

    Thank You. Works very well !!!
    Last edited by gachua1978; 02-11-2014 at 05:15 PM.

+ 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] How to merge multiple excel files(xls) in one folder into a new xls file.
    By Hayk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2013, 11:48 AM
  2. Merge multiple excel files into one with multiple sheets
    By madmanmarz in forum Excel General
    Replies: 3
    Last Post: 05-23-2012, 10:10 AM
  3. How to merge multiple excel files..?
    By clone000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2010, 05:51 PM
  4. How to merge multiple Excel Files into One File
    By janeshh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2009, 08:09 AM
  5. Is it possible to merge columns for HMTL output?
    By Heartache in forum Excel General
    Replies: 3
    Last Post: 10-22-2005, 09:12 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