+ Reply to Thread
Results 1 to 3 of 3

Match Data on Another Worksheet and Copy/Paste Range

  1. #1
    Registered User
    Join Date
    04-11-2014
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    28

    Match Data on Another Worksheet and Copy/Paste Range

    Hi there,
    I am trying to match ID#s in column C of Preliminary worksheet to ID#s in column C of Final worksheet. If there is a match, then copy cell content (url links) from column D of Preliminary worksheet to column D of Final worksheet. I am getting a compile error: Object required. Can you please review my code and see where I have gone wrong. Or if this code could be simplified. Thank you so much. File attached.


    Sub RangeFind()

    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim lastrow1 As Long, lastrow2 As Long, nextrow, c

    Application.ScreenUpdating = False

    Set ws1 = ThisWorkbook.Sheets("Final")
    Set ws2 = ThisWorkbook.Sheets("Preliminary")
    Set lastrow1 = ws1.Range("C" & Rows.Count).End(xlUp).Row
    Set lastrow2 = ws2.Range("C" & Rows.Count).End(xlUp).Row

    'Loop through Preliminary worksheet, Column C
    For nextrow = 2 To lastrow1

    'Search Final worksheet Column C for value from Import
    With ws2.Range("C2:C" & lastrow2)
    Set c = .Find(ws2.Range("C" & nextrow), LookIn:=xlValues, LookAt:=xlWhole)

    'Copy Preliminary worksheet row if match is found
    If Not c Is Nothing Then
    ws2.Range("D" & nextrow).Copy _
    Destination:=ws1.Range("D" & c.Row)
    End If
    End With
    Next

    Application.ScreenUpdating = True

    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Match Data on Another Worksheet and Copy/Paste Range

    Hi,
    try this way:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-11-2014
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Match Data on Another Worksheet and Copy/Paste Range

    Thank you so much Mr. Vevrku. Your solution worked perfectly and I loved your explanations as they were a great source of learning opportunity.

    Beautiful work!!!!

    Thank you!!!!

+ 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. Get VBA to match cell data with a worksheet name and then copy and paste a cell
    By Maaarie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2019, 12:26 PM
  2. [VBA] Search worksheet for match and copy/paste
    By lababa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2018, 08:12 AM
  3. VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2014, 04:06 PM
  4. Match Cell Value to Worksheet Name Then Copy/ Paste Range to Worksheet
    By matt2072 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-31-2014, 01:23 PM
  5. Find, Match, Copy Paste Value to another worksheet
    By vty in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2013, 01:37 AM
  6. Copy range from worksheet based on data in a column and paste to end of another ws
    By DavyNixon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-18-2005, 01:29 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