![]() |
Macro correction
Hi,
I've got the following code to copy every 3rd cell in col C starting from the last row -1 and paste into next blank row +1 of col A in different workbook. This works great. Then I tried to alter it to do a similar action... Copy every 3rd cell in col C starting from the last row and paste into next blank row +1 of col H in other workbook. At the moment the second part of the code copies the same values as the first part, what do I change to copy the last cell in col C not the one above?? I've fiddled with the End(xlUp) part but then get errors. Any help greatly appreciated, thanks... 'Copy every 3rd cell in column C starting one row before the last row, and paste into next blank row +1 in LFmacro worksheet col A For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "A") End With Next i 'Copy every 3rd cell in column C starting at the last row, and paste into next blank row +1 in LFmacro worksheet col H Windows("Discreps.xls").Activate For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "H") End With Next i |
Macro correction
Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i + 1, "c").Copy .Cells(Lr, "H") End With Next i -- Regards, Tom Ogilvy "Meltad" wrote: Hi, I've got the following code to copy every 3rd cell in col C starting from the last row -1 and paste into next blank row +1 of col A in different workbook. This works great. Then I tried to alter it to do a similar action... Copy every 3rd cell in col C starting from the last row and paste into next blank row +1 of col H in other workbook. At the moment the second part of the code copies the same values as the first part, what do I change to copy the last cell in col C not the one above?? I've fiddled with the End(xlUp) part but then get errors. Any help greatly appreciated, thanks... 'Copy every 3rd cell in column C starting one row before the last row, and paste into next blank row +1 in LFmacro worksheet col A For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "A") End With Next i 'Copy every 3rd cell in column C starting at the last row, and paste into next blank row +1 in LFmacro worksheet col H Windows("Discreps.xls").Activate For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "H") End With Next i |
Macro correction
Thanks Tom,
i +1!!! "Tom Ogilvy" wrote: Windows("Discreps.xls").Activate For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i + 1, "c").Copy .Cells(Lr, "H") End With Next i -- Regards, Tom Ogilvy "Meltad" wrote: Hi, I've got the following code to copy every 3rd cell in col C starting from the last row -1 and paste into next blank row +1 of col A in different workbook. This works great. Then I tried to alter it to do a similar action... Copy every 3rd cell in col C starting from the last row and paste into next blank row +1 of col H in other workbook. At the moment the second part of the code copies the same values as the first part, what do I change to copy the last cell in col C not the one above?? I've fiddled with the End(xlUp) part but then get errors. Any help greatly appreciated, thanks... 'Copy every 3rd cell in column C starting one row before the last row, and paste into next blank row +1 in LFmacro worksheet col A For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "A") End With Next i 'Copy every 3rd cell in column C starting at the last row, and paste into next blank row +1 in LFmacro worksheet col H Windows("Discreps.xls").Activate For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3 With Workbooks("LFmacro.xls").Sheets("Report") Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i, "c").Copy .Cells(Lr, "H") End With Next i |
All times are GMT +1. The time now is 11:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com