RoganLogan
New Member
- Joined
- Dec 7, 2011
- Messages
- 45
Hi,
I am trying to copy some data from sheet 3 of my workbook and then paste it on sheet 2 with two criteria. The criteria being that some text in Cell A10 of sheet 3 must match the text in Column B of sheet 2 and that a date in Cell BI1 of sheet3 matches the date in Column C of sheet2. I then need to paste the data in the next column D.
i've had a go at making a loop below and although it does seem to loop through the data trying to match the both the text and date it just however pastes the data in the last cell I have clicked on in sheet2. Not sure if I am approaching the problem correctly but any help would be greatly appreciated.
Thanks for your time.
I am trying to copy some data from sheet 3 of my workbook and then paste it on sheet 2 with two criteria. The criteria being that some text in Cell A10 of sheet 3 must match the text in Column B of sheet 2 and that a date in Cell BI1 of sheet3 matches the date in Column C of sheet2. I then need to paste the data in the next column D.
i've had a go at making a loop below and although it does seem to loop through the data trying to match the both the text and date it just however pastes the data in the last cell I have clicked on in sheet2. Not sure if I am approaching the problem correctly but any help would be greatly appreciated.
Code:
Sub Move_DA_Forecast()Dim Sheet2 As Worksheet
Dim PV As Worksheet
Set Sheet2 = ThisWorkbook.Sheets("Sheet2")
Set Sheet3 = ThisWorkbook.Sheets("Sheet3")
Sheets("Sheet3").Select
Range("B10").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet2").Select
LR = Sheet2.Cells(Rows.Count, 3).End(xlUp).Row
PVEXC = Sheet3.Cells(10, 1)
DA = Sheet3.Cells(1, 61)
'loop
For x = 5 To LR
If Sheet2.Cells(x, 3) = DA And Sheet2.Cells(x, 2) = PVEXC Then
ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues
End If
Next x
End Sub
Thanks for your time.