Macro Copy Cells between sheets in Excel

Closed
AJ - Aug 10, 2010 at 12:49 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Aug 10, 2010 at 02:44 PM
Hello,

I am relatively new to macros and am having trouble with a code. I would greatly appreciate any help you can give me.

The problem is I have two worksheets and I need to copy the data from a cell in Sheet2 to a cell in Sheet1 if the values of two other rows equal. So, if the values of any cell from A12:A100 in Sheet2 equals the value of any cell from F12:F40 in Sheet1, then I need the corresponding value in the D column of Sheet2 to go to the N column of Sheet1. Below is a code I wrote, but it only compares one set of cells at a time. To use this I would have to have over 2000 (For codes) in the one macro.

Private Sub CommandButton2_Click()

    For Each Cell In Sheets("PASTE").Range("A12")
    
    If Cell.Value = Sheets("TSS").Range("F12") Then
    
    Sheets("PASTE").Select
    Range("D12").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("TSS").Select
    Sheets("TSS").Range("N12").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats = Empty, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False

    End If

    Next
    
End Sub



Again, I appreciate any help you can give me.

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Aug 10, 2010 at 02:44 PM
What you mean by "cell matching"

Could you please upload a sample EXCEL file WITH sample data, macro, formula , conditional formatting etc on some shared site like https://authentification.site , http://docs.google.com, http://wikisend.com/ , http://www.editgrid.com etc
A N D post back here the link to allow better understanding of how it is now and how you foresee. Based on the sample book, could you re-explain your problem too
1