billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
Could use a little help
attempting again here to copy if two criteria is met to another workbook. Using Code below
Sub copyMC()
Dim lastrow As Long
Dim lastrow2 As Long
Dim i As Long
lastrow = Workbooks("Book10").Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
lastrow2 = Workbooks("SalesMaster").Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, "A").Value = Date And Cells(i, "B").Value = "Sales" Then
Rows(i).Copy Destination:=Workbooks("Book10").Sheets("Sheet1").Range("A" & lastrow2 + 1)
lastrow2 = Workbooks("SalesMaster").Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
'Workbooks("Book10").Sheets("Sheet1").Rows(1).Copy Destination:=workbook(sSheets("Sheet1").Rows(1)
The above is an attempt to copy header row
End If
Next i
End Sub
attempting again here to copy if two criteria is met to another workbook. Using Code below
Sub copyMC()
Dim lastrow As Long
Dim lastrow2 As Long
Dim i As Long
lastrow = Workbooks("Book10").Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
lastrow2 = Workbooks("SalesMaster").Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, "A").Value = Date And Cells(i, "B").Value = "Sales" Then
Rows(i).Copy Destination:=Workbooks("Book10").Sheets("Sheet1").Range("A" & lastrow2 + 1)
lastrow2 = Workbooks("SalesMaster").Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
'Workbooks("Book10").Sheets("Sheet1").Rows(1).Copy Destination:=workbook(sSheets("Sheet1").Rows(1)
The above is an attempt to copy header row
End If
Next i
End Sub