Macro Copy Cells between sheets in Excel

Closed
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
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.

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
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
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month