+ Reply to Thread
Results 1 to 4 of 4

macro to copy the values in only 2 columns of an excel file based on a condtion to another

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Gulbarga
    MS-Off Ver
    Excel 2007
    Posts
    15

    macro to copy the values in only 2 columns of an excel file based on a condtion to another

    I want copy the values in only two columns (Prod_code) & (Total)from three tables in an excel file (source file) to another excel file (target file), if the value in a particular column (Prod_code)of the first file, starts with 12345.
    The first twelve records of the source file look as under:
    source.PNG
    Further, I want to inform you that the source file (first file) has the following features:
    1. The file contains three similar tables. I mean the structure of the three tables is the same.
    2. All the three tables have blank rows here & there in the three tables.
    3. There are some text entries above & below the three tables.
    Conditions for the target file:
    1. Only the Prod_codes starting with 12345 should be listed in the target file.
    2. There should not be any blank rows in the target file.
    3. The records in the target file should appear in the same order as that of the source file.
    The first twelve records of the target file should look as under:
    target.PNG
    The source_file.xls & target_file.xls are sent attached.
    I am just a beginner regarding excel macros.
    I tried recording a macro but the recorded macro is not working properly .
    Any of you please guide me in this matter.
    Regards,
    cbk40060
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro to copy the values in only 2 columns of an excel file based on a condtion to ano

    Give this a try, be sure to edit the SaveAs path to where you want the new file saved.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Gulbarga
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: macro to copy the values in only 2 columns of an excel file based on a condtion to ano

    Thanks JBeaucaire, the macro works very well.
    Attached Files Attached Files
    Last edited by JBeaucaire; 09-14-2015 at 02:57 AM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro to copy the values in only 2 columns of an excel file based on a condtion to ano

    Additional questions moved to a new thread.

+ 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. Macro to copy the range of values from Excel and paste in html file
    By harishpeddi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2014, 10:50 AM
  2. [SOLVED] Copy/Paste multiple columns as values based on another columns criteria
    By Dgp2012 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-28-2013, 06:50 AM
  3. Match Column based on Condtion
    By foncesa in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-23-2013, 10:07 PM
  4. Macro to COPY and PASTE VALUES for in columns based on the date
    By tompee29 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 10:54 AM
  5. Copy-Paste Macro of 3 columns from multiple excel files into one summary file
    By jpmaster53 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2012, 07:10 AM
  6. Copy rows to another sheet on condtion
    By naflas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2011, 07:22 AM
  7. Macro to open file, copy paste as values and save as excel html
    By gsav in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-18-2011, 10:15 AM
  8. Replies: 1
    Last Post: 02-27-2006, 11:40 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