Copy a row, paste its values, move to next row, move to another sheet and etc

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.

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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Update: It seems it is not doing it to all the different workbooks. Some are okay and doesn't paste the whole information below the current row....which is strange... I created different modules and I am starting them for each different workbook...could that be the problem ?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top