ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy a range of cells 15 rows down and repeat to empty cell (https://www.excelbanter.com/excel-programming/412152-copy-range-cells-15-rows-down-repeat-empty-cell.html)

Mike V

Copy a range of cells 15 rows down and repeat to empty cell
 
I have Excel 2003 and Windows XP.
My spreadsheet is currently 8,240 lines. I want to copy a range (containing
both absolute and relative cell references) of 15 lines and copy the range
down the 8,000 lines. The code I've tried is:

Sub loop1()
'this loop runs until there is nothing in the next column
Do
Range(Range("K7:R21"), Range("k7:R21").End(xlDown)).Copy Range("K22")
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
End Sub

It copies one line at a time and bogs down in fairly short order.

--
M.R. Vanatta

Per Jessen[_2_]

Copy a range of cells 15 rows down and repeat to empty cell
 
On 5 Jun., 23:05, Mike V wrote:
I have Excel 2003 and Windows XP.
My spreadsheet is currently 8,240 lines. *I want to copy a range (containing
both absolute and relative cell references) of 15 lines and copy the range
down the 8,000 lines. *The code I've tried is:

Sub loop1()
'this loop runs until there is nothing in the next column
Do
Range(Range("K7:R21"), Range("k7:R21").End(xlDown)).Copy Range("K22")
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
End Sub

It copies one line at a time and bogs down in fairly short order.

--
M.R. Vanatta


Hi

Which cell is the ActiveCell at the start of the macro, ie which
column is used to determine last row to copy to?

Regards,
Per

Mike V

Copy a range of cells 15 rows down and repeat to empty cell
 
The active cell is K7 when the macro starts.
--
M.R. Vanatta


"Per Jessen" wrote:

On 5 Jun., 23:05, Mike V wrote:
I have Excel 2003 and Windows XP.
My spreadsheet is currently 8,240 lines. I want to copy a range (containing
both absolute and relative cell references) of 15 lines and copy the range
down the 8,000 lines. The code I've tried is:

Sub loop1()
'this loop runs until there is nothing in the next column
Do
Range(Range("K7:R21"), Range("k7:R21").End(xlDown)).Copy Range("K22")
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
End Sub

It copies one line at a time and bogs down in fairly short order.

--
M.R. Vanatta


Hi

Which cell is the ActiveCell at the start of the macro, ie which
column is used to determine last row to copy to?

Regards,
Per



All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com