+ Reply to Thread
Results 1 to 4 of 4

Macro in excel to copy specific values from a table with a specific criteria

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    60

    Macro in excel to copy specific values from a table with a specific criteria

    I want to make a macro in excel that makes the following steps:
    1. Search a specific String in a specific column ("D")
    2. Copy some values from specific columns of that table, which have the specific string (I had searched in step 1) in the column D, to another worksheet.


    So in order to do this I have:
    Please Login or Register  to view this content.
    Now I'm not sure how to manipulate the range variable I got from the search. How can I say for example, regarding the table bellow, that I want to copy the values from the "Country" and Population columns that corresponds to the "Lisbon" value in the city column to another worksheet ?

    ptINZ.jpg

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Macro in excel to copy specific values from a table with a specific criteria

    Hi Adam,

    Try:
    Please Login or Register  to view this content.
    Another way would be to use autofilter on the currentregion, set a filter on Column D and then copy the values.

    Hope this helps,
    berlan
    Last edited by berlan; 05-11-2015 at 12:56 PM.

  3. #3
    Registered User
    Join Date
    03-01-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Macro in excel to copy specific values from a table with a specific criteria

    Hi Berlan,

    Thanks for the tip. I've some doubts on your code though. In the last part, why do you do the Intersect stuff? I adapted the code to my files and became something like the code bellow where I want to paste the information in a another workbook begining in the Cell A15. When I run the macro it gives me a warning box saying "Run Time Error '9': Subscript out of range"




    Please Login or Register  to view this content.
    I had tried also replace the Itersect part for something more basic like the code bellow but it also failed giving me the same message

    Please Login or Register  to view this content.
    Can you help me again?

    Thanks

  4. #4
    Registered User
    Join Date
    03-01-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Macro in excel to copy specific values from a table with a specific criteria

    Hi again Berlan,

    I solve that problem with minor changes. End up with the final code bellow (just changed the Intersect part). Just one more question, If I want to copy another column beside the ones comprised by the A:D range i.e if I want to copy the A:D range plus the Z column how can I do the intersection?

    Once again, thanks for the help =)

    Please Login or Register  to view this content.

+ 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] Macro to copy specific data from one WB to specific cells in another WB based on specific
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 11:05 AM
  2. Macro to copy specific line from text file and paste into specific cell in excel
    By keeneye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:35 AM
  3. HELP! Macro to Copy specific cells from one sheet to another based on specific criteria
    By atriscritti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-11-2012, 11:05 AM
  4. [SOLVED] How do I use a lookup table to sum values for specific criteria?
    By NJLExcel1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2012, 02:57 PM
  5. Macro to copy specific data to specific columns from a pivot table
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2012, 07:24 PM

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