dilyanyordanov
New Member
- Joined
- Dec 5, 2016
- Messages
- 17
Hi guys, I am going to say what I am trying to accomplish in words. I have a report I was doing manually. The info is imported into different workbooks from a master excel file. From then i was copying and pasting each row as of the different days of the month. This could be automated so I have this code. The way i think it should be is, after the data is imported, i need to copy the selected row, paste it as values, move to the next row so the next day it could start copying and pasting from the correct row, move to the next sheet, then the next sheet and so on. The code works fine but after I did it for the second workbook i found out that everything is correct with the first sheet, then the second, third and so on sheets , the data from the row below it is being pasted as values and this shouldn't happen since the references must be there to extract data from the master sheet the next day. I can't get to why this is doing it since the code is the same for all the sheets, i just add an "activate" function before the row is being copied and pasted on the second sheet.
Thanks for the help in advance.
Thanks for the help in advance.
Code:
Sub CopyAndPasteRowsSalesmen1()
'copy and paste for Worker 1'
Dim irow As Long
irow = ActiveCell.Row
Range(Cells(irow, "A"), Cells(irow, "L")).Copy
Range(Cells(irow, "A"), Cells(irow, "L")).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("A" & ActiveCell.Row + 1).Select
'copy and paste for Worker 2'
Worksheets("Worker 2").Activate
Dim irow2 As Long
irow2 = ActiveCell.Row
Range(Cells(irow, "A"), Cells(irow2, "L")).Copy
Range(Cells(irow, "A"), Cells(irow2, "L")).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("A" & ActiveCell.Row + 1).Select
'copy and paste for Worker 3"
Worksheets("Worker 3").Activate
Dim irow3 As Long
irow3 = ActiveCell.Row
Range(Cells(irow, "A"), Cells(irow3, "O")).Copy
Range(Cells(irow, "A"), Cells(irow3, "O")).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("A" & ActiveCell.Row + 1).Select
'move to First sheet again at the end of cycle'
Worksheets("Worker1").Activate
Application.CutCopyMode = False
End Sub