Excel macro paste row for certain num of rows [Closed]

Report
Posts
2
Registration date
Monday September 14, 2009
Status
Member
Last seen
September 17, 2009
-
Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
-
Hello,

I have a row with data that I reach from a blank row below and perform a count of the number of rows elapsed to get to the row with data. After recording this manually (using a row count macro ofcourse), this is the code that got generated so far:

Range(Selection, Selection.End(xlUp)).Select
Application.Run "Results_BW.xls!CountRow"

Where the code for CountRow is:

Sub CountRow()
myCountRow = Selection.Rows.Count

All I would like to know is how to get Excel to copy a row a certain number of rows below it, where the number is the row count I just performed.

If there is any need for further clarification then please let me know! Any help is appreciated.

2 replies

Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
307
Hello

Just try
Rows(selection.row).Copy
Rows(Selection.Rows.Count ).Select
ActiveSheet.Paste
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 4198 users have said thank you to us this month

Posts
2
Registration date
Monday September 14, 2009
Status
Member
Last seen
September 17, 2009

Thanks.

There is 1 more restriction however. The row copied is within the first 8 columns, and not beyond as those columns contain other data.

The code Excelguru suggested...
Rows(selection.row).Copy
Rows(Selection.Rows.Count ).Select
ActiveSheet.Paste


..seems to work for the entire row, but I only want to copy the first 8 column of the row, and extend the first 8 column into the rows below (number of rows determined by count).
Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
307
Hello,

Try this

range(cells(selection.row,1),cells(selection.row+count,8)).copy