+ Reply to Thread
Results 1 to 7 of 7

VBA Copy Range to another sheet if data matches

  1. #1
    Forum Contributor
    Join Date
    02-16-2006
    MS-Off Ver
    OFFICE 365
    Posts
    244

    VBA Copy Range to another sheet if data matches

    I have a situation where I need to copy a range (a:j) to a sheet (named Existing) if a criteria is met and copy the same range to a sheet (named New) if a criteria is not met. I have four sheets: Details, Master, Existing, & New. If the data in columns A & B, in Details, matches the data in columns A & B, in Master, I want to copy the columns a:j for that row to the sheet named Existing. If not, I want to copy columns a:j to the sheet named New. I have attached a sample spreadsheet to hopefully better explain what I am looking for. Any help would be appreciated.


    Thanks,

    Met
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: VBA Copy Range to another sheet if data matches

    Are you copying from Master to Existing and New, or from Details to Master and New?

    In your example, Master contains all matches from New and Existing, but Details doesn't. The order has me a little confused.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Contributor
    Join Date
    02-16-2006
    MS-Off Ver
    OFFICE 365
    Posts
    244

    Re: VBA Copy Range to another sheet if data matches

    daffodil11:

    Thanks for your response. I should have clarified this a bit better. If the data Matches then copy the information from Details to Existing. If the data does not match then copy the data from Master to New.


    Thanks,

    Met

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Copy Range to another sheet if data matches

    Try the attached.
    I have not read your post when I post the reply.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-16-2006
    MS-Off Ver
    OFFICE 365
    Posts
    244

    Re: VBA Copy Range to another sheet if data matches

    AB33:

    Thanks for the response. The script works perfectly. However, I failed to mention that the sheet labeled Master contains significant data and I only want/need items in the Details sheet to be copied over to the Existing and New Tabs. Rather, if the criteria in the Details sheet finds a match in the Master sheet the row from the Details sheet is moved to existing. If not, the row is moved to New.

    The current script moves all the non matches to new.

    Thanks,

    Met

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Copy Range to another sheet if data matches

    Amended code:
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-16-2006
    MS-Off Ver
    OFFICE 365
    Posts
    244

    Re: VBA Copy Range to another sheet if data matches

    Works great. Thanks!

+ 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] Copy datas in sheet if value matches
    By heiderayos in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 09-15-2014, 08:55 PM
  2. Copy Data from one sheet to another if column data matches
    By solsearcher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-09-2013, 07:01 AM
  3. [SOLVED] Copy row if value matches 'Sheet'!B1
    By ngocpdn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2013, 11:54 PM
  4. Copy values from previous day, if range matches
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-22-2012, 09:29 AM
  5. Replies: 1
    Last Post: 10-30-2009, 10:58 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