+ Reply to Thread
Results 1 to 12 of 12

Macro to copy rows of data based on a value supplied

  1. #1
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Macro to copy rows of data based on a value supplied

    I have attached a simple workbook which I would like to copy rows of data that matches my search criteria to another workbook. For example, in column A, I would like to copy all the rows of data to a new workbook any row with "SK". Or I may want to copy rows of data that MB is chosen in column A. This could be simply by entering SK in a certain cell or a userform. Thanks for the base as the actual spreadsheet has many more rows and columns, but all I need is the basics and I can build from there!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    Base code to start with
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Macro to copy rows of data based on a value supplied

    Wow jindon! Thanks for such a quick reply!! It works 100% as I asked, but I forgot to include the ability to omit a column, say for example column D?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    The add one line
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Macro to copy rows of data based on a value supplied

    Awesome jindon! Is there a way to add that to the inputbox so it is variable, meaning one time it might be column "D", the next it might be column "E"?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    What's more do you want to ask?

    I posted the basic code due to the vague question.

  7. #7
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Macro to copy rows of data based on a value supplied

    Quote Originally Posted by jindon View Post
    What's more do you want to ask?

    I posted the basic code due to the vague question.
    Yes, I know, I do this everytime, I always don't think it through enough when I ask the initial question, then as answers come, I think of another thing. I am sorry about that and promise, that is the last change.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    What I was trying to say is that as you ask one by one, it will be a very messy code in the end.
    If you ask all in one, we can build a better code even with a different method sometime, so it would be a loss of time for you and us.

    UserForm is the way to go for me in this case.
    To a Standard code module
    Please Login or Register  to view this content.
    To a UserForm (ComboBox x 2, CommandButton x1) code module
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 09-13-2016 at 11:04 PM.

  9. #9
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Macro to copy rows of data based on a value supplied

    Yes, I understand and hear you jindon and again am sorry for this. Thanks for ALL of your help and this is a good base for me to work from. MUCH appreciated!!

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    You are welcome and thanks for the rep.

  11. #11
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Macro to copy rows of data based on a value supplied

    As you can see above, I really appreciate the effort jindon has done and provided me with an excellent base to build from. His last proposal works great, but not exactly what I am after.

    1) The ability to filter one column, for example A.
    2) The ability to not include one or more columns, for example D, but could be any combo of 1 or more columns.
    3) Create a new workbook as the result of 1 & 2 above.

    I see that I worded it wrong above, thus why the further request.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,696

    Re: Macro to copy rows of data based on a value supplied

    1) Think deeply how it should be handled.
    2) Build your own UserForm with controls that enables you to enter information for above, if you need one. (no code)
    3) If you don't need UserForm, propose other means of entering information.

    You should do above before you ask.

+ 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 copies rows based on condition, BUT rows copy in Wrong order. PLEASE HELP!
    By JAllard1990 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2014, 04:33 PM
  2. Macro to copy rows based on moving date and paste the rows into an identical sheet
    By ivandc1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2014, 11:59 AM
  3. [SOLVED] Macro to copy rows based on a critera and copy the name of the column
    By dreddster in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-10-2013, 11:34 AM
  4. [SOLVED] insert rows based on number in cell and copy the data down into the new rows
    By pziefle in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-05-2013, 11:19 AM
  5. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 PM
  6. [SOLVED] Macro to match and Pull data EXAMPLE SUPPLIED
    By ad9051 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2012, 05:08 PM
  7. Macro to copy data in rows based on criteria
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2010, 10:24 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