Results 1 to 7 of 7

Copy the row to another sheet when the value of a cell matches

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2019
    Location
    Chile
    MS-Off Ver
    365
    Posts
    8

    Copy the row to another sheet when the value of a cell matches

    Hi,

    I have a problem that I could not solve.

    I have two tables, where in column "A" of table 1 has values ​​that appear in column "A" of table 2 (these tables are on separate sheets).

    The data in column "A" in table 1 is never repeated.
    The data in column "A" in table 2 are the same as in column "A" in table 1 but they are repeated.

    I need a macro that looks for each of the cells in column A of table 1 in column A of table 2, and when they match, copy the row in table 1 and paste it over the row in table 2.

    The data in table 1 should only be copied once in table 2, on the first cell that matches

    I leave a sample file in case they need it, and this is the code that I have been occupying but it doesn't work for me.

    Sub Findandcopy()
    
            Dim lr As Long
            Dim i As Integer
    
    lr = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
    
    For i = 1 To lr
    
    If UCase(Sheet2.Cells(1, 1).Value) = UCase(Sheet1.Cells(i, 1).Value) Then
        Sheet2.Cells(1, 1).Value = Sheet1.Cells(i, 1).Offset(, 1).Value
          End If
    Next i
    
    End Sub
    Thank you!!!
    Attached Files Attached Files
    Last edited by Ghuphuneho; 08-28-2019 at 04:04 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. If name on sheet 1 matches in sheet 2, copy data over
    By marcoandretti25 in forum Excel General
    Replies: 1
    Last Post: 10-30-2018, 11:57 AM
  2. Replies: 6
    Last Post: 05-29-2017, 04:16 PM
  3. [SOLVED] Copy Column A data to Sheet 2 where rows matches Sheet 2 headers
    By SCDE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2015, 12:14 AM
  4. [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
  5. [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
  6. Replies: 4
    Last Post: 08-23-2012, 05:26 AM
  7. 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