Results 1 to 4 of 4

Search for multiple matching cells and copy/paste range?

Threaded View

papercut Search for multiple matching... 04-01-2014, 07:23 AM
RudiS Re: Search for multiple... 04-01-2014, 08:30 AM
papercut Re: Search for multiple... 04-01-2014, 10:37 AM
RudiS Re: Search for multiple... 04-01-2014, 11:24 AM
  1. #1
    Registered User
    Join Date
    04-01-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2011 Mac, 2013 PC
    Posts
    2

    Search for multiple matching cells and copy/paste range?

    Hi there,

    I have a very large spreadsheet (>500000 rows) and need to consolidate the data between the sheets. Can someone please assist me in creating a macro that would search for a row in 1 sheet that has the exact same values for two columns (in the same row) in another sheet?

    I have tried to simplify my spreadsheet and have attached a file that includes only 10 rows of data.

    Basically, in the sheet "sche", I need to search columns A and B for a row that exactly matches the values in a row in sheet "act", columns D, and E, respectively. If there is a match, I need to copy the range "C:AO" of the matched row from "sche" and paste into F of "act".

    Using some answers I found on Mr.Excel and Yahoo Answers, I have drafted a novice code - but obviously, I cannot get it to run.

    I also don't know how to declare my variables.
    Values in columns A ("sche") and D ("act") are integers.
    However, values in column B ("sche") and E ("act") are dates in the format YYYY-MM-DD.

    Sub Consolidate_Data()
        
        Dim i, j, LRSche, LRAct
        
        LRSche = Sheets("sche").Range("A" & Rows.Count).End(xlUp).Row
        LRAct = Sheets("act").Range("D" & Rows.Count).End(xlUp).Row
        
        For i = 1 To LRSche
        For j = 1 To LRAct
        
        If Sheets("sche").Cells(i, "A").Value = Sheets("act").Cells(j, "D") Then
        If Sheets("sche").Cells(i, "B").Value = Sheets("act").Cells(j, "E") Then
        Sheets("sche").Cells(i, "C").Resize(, 38).Copy
        Sheets("act").Cells(j, "F").Paste
        
        End If
        End If
        Next i
        Next j
        
    End Sub
    I appreciate any help I can get and thank you very much in advance!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 11-26-2013, 04:53 AM
  2. Replies: 1
    Last Post: 11-25-2013, 09:30 AM
  3. Copy/Paste range of cells to another worksheet based on matching criteria
    By maa50904 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2013, 12:07 AM
  4. Replies: 1
    Last Post: 01-17-2013, 05:27 PM
  5. [SOLVED] Search workbook for matching detail and copy/paste the row/column content.
    By GB.RTMC in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-28-2012, 09:55 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