+ Reply to Thread
Results 1 to 7 of 7

VBA to copy to new sheet and paste to last empty row based on criteria

  1. #1
    Registered User
    Join Date
    05-09-2019
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    25

    VBA to copy to new sheet and paste to last empty row based on criteria

    Hi all,

    I'm trying to use a macro to copy data from sheet A to sheet B based on a criteria

    as attached in this scenario i would like for it to review column C in sheet 1 (Master data) for anything that shows the word "query" then copy that entire row into the first blank row of the second sheet (Queries)

    there is some bad code in there and it does find the right rows to move but it puts them in adjacent position to where they are in sheet 1 which is not the required result

    the end result i want to load new data daily into sheet1 approx 25000 rows with expected queries less than 100 and so each day it will add anything as query to sheet 2 so this list will get bigger over time recording all the queries


    Many thanks in advance for your help
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    .
    One method :

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-09-2019
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    25

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    Thank you for your help, i really appreciate it. ive added it to my spreadsheet but it is copying over existing rows when pasting to sheet 2 "queries" is there a way to make it so each time the macro is run it will paste to the bottom of the data that already exists in "Queries" to the first blank row?

    so for example i drop the data in the master sheet i pick up 2 queries so when the macros finished sheet 2 "queries will have 2 rows of data. then tomorrow i drop my new data in and pick up 3 queries so the macro will then add it to what was there today and there is now 5 rows of data etc hopefully that makes sense!

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    .
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-09-2019
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    25

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    Thank you Logit thats amazing, you nailed it!

    I really appreciate your help

  6. #6
    Registered User
    Join Date
    05-09-2019
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    25

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    Hi Logit, i do have one question however i have added this to my sheet and it works well where the sheet is format as the example however i tried to adapt it to look at something else in column T on the same spreadsheet but when i change

    If Sheets("Master Data").Range("C" & i).Value = "query" Then

    to

    If Sheets("Master Data").Range("T" & i).Value = "query" Then


    then it does not work all other parameters remain the same so the simple fix of changing the column letter does not work can i bother you one more time for your help to understand how i can make it look to a different column

    thank you

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to copy to new sheet and paste to last empty row based on criteria

    .
    Hmm ... not certain what to advise. I made the change here to column T and it functions well.

    Please Login or Register  to view this content.
    I presume you are still seeking the term query ?

    If the term has changed you will need to change it in the macro code as well.

+ 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. Copy & Paste from an Excel Sheet to Another sheet Based on Certain Criteria
    By SPAARK in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-04-2019, 10:14 PM
  2. [SOLVED] VBA to Copy & paste values from one sheet to another based on criteria.
    By rossi_69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2018, 08:04 AM
  3. [SOLVED] Copy and paste columns to another sheet based on a criteria
    By saya_26 in forum Excel General
    Replies: 17
    Last Post: 02-24-2014, 12:23 PM
  4. [SOLVED] Copy/Paste a column in a new sheet based on a criteria
    By Elorac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2013, 02:01 PM
  5. [SOLVED] Copy & Paste to another sheet based on criteria on next blank row
    By Webbers in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-06-2013, 04:09 PM
  6. Copy and Paste Rows based on Criteria onto another sheet and sort based on oldest item
    By Kushal8684 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 05:37 AM
  7. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 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