mikenelena
Board Regular
- Joined
- Mar 5, 2018
- Messages
- 139
- Office Version
- 365
- Platform
- Windows
Hello, and thanks in advance for any suggestions.
I would like to copy certain partial rows [from columns A-H] from sheet1 to sheet2 if 2 criteria (name and date both match fields in sheet2) are met. I'm about 85% of the way there, but I'm stuck on 2 issues. The first is that the code I have is pasting entire rows, which overwrites my data in downstream columns on Sheet2. I cannot seem to get my mind around a way to limit the copy to columns A-H. (Total novice here.)
The second issue is that I cannot seem to get the range pasted with values only.
If anyone can suggest anything, I would most appreciate it.
Thanks again!
I would like to copy certain partial rows [from columns A-H] from sheet1 to sheet2 if 2 criteria (name and date both match fields in sheet2) are met. I'm about 85% of the way there, but I'm stuck on 2 issues. The first is that the code I have is pasting entire rows, which overwrites my data in downstream columns on Sheet2. I cannot seem to get my mind around a way to limit the copy to columns A-H. (Total novice here.)
The second issue is that I cannot seem to get the range pasted with values only.
If anyone can suggest anything, I would most appreciate it.
Thanks again!
Code:
Sub CommandButton1_Click()
A = Worksheets("Main").Cells(Rows.Count, 1).End(xlUp).Row
For I = 2 To A
If Worksheets("Main").Cells(I, 3).Value = Worksheets("Sheet2").Cells(1, 10) And Worksheets("Main").Cells(I, 7).Value = Worksheets("Sheet2").Cells(1, 12) Then
Worksheets("Main").Rows(I).Copy
Worksheets("Sheet2").Activate
B = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet2").Cells(B + 1, 1).Select
Worksheets("Sheet2").Paste
End If
Next I
Application.CutCopyMode = False
End Sub