Consulting

Results 1 to 4 of 4

Thread: Solved: Copy row of sheet2 (if data does not match sheet1).

  1. #1

    Solved: Copy row of sheet2 (if data does not match sheet1).

    Hello friends,

    The attachment here has a code that works, I need to edit the code to:
    1. Go thru column A of sheet2.
    2. if the data in column A of sheet2 does not exist in column A of sheet1, then copy the active row from column A to column D (of sheet2), and paste the rows on sheet3.
    3. Start the pasting on cell A11 on sheet3.

    The reasons why the code that I attach is not enough, is due to:
    A. The code copies the matches between the two A columns (I don't the matches to be copied).
    B. The code only copies the last column of the matching A data (I need the entire row).

    Thanks a lot for your time & efforts,
    Nawaf
    Last edited by countryfan_n; 06-12-2008 at 07:21 PM.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub DoCompare()
    Dim cel As Range, tgt As Range
    With Sheets("Sheet2")
    For Each cel In Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
    If Sheets("Sheet1").Columns(1).Find(cel) Is Nothing Then
    Set tgt = Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1)
    If tgt.Row < 11 Then Set tgt = Sheets("Sheet3").Cells(11, 1)
    cel.Resize(, 4).Copy tgt
    End If
    Next
    End With
    End Sub[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thank you very much for your time and efforts!

    I am wondering though, since it is copying and pasting, can it copy & paste the text with a "Proper" text format?

    Thanks again
    Nawaf
    Last edited by countryfan_n; 06-17-2008 at 03:29 AM.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, it would have to process that after pasting.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •