ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   copy rows and paste onto visible only (https://www.excelbanter.com/excel-discussion-misc-queries/260853-copy-rows-paste-onto-visible-only.html)

rk0909

copy rows and paste onto visible only
 
All,

I want to copy say 10 rows and then paste into another 10 rows. Problem is
the destination rows are not contiguous. there are 4-5 rows in between each
of these rows which are grouped.

is there a way to do that. I tried the visible cells property but that does
not work.

Any help of direction is much appreciated.

thanks much,

RK

ozgrid.com

copy rows and paste onto visible only
 
Something like;

Sub CopyToVisibleRows()
Dim rCell As Range, rCell2 As Range
Dim lPasteRow As Long

lPasteRow = 1
For Each rCell In Sheet1.Range("A1:A10")
rCell.EntireRow.Copy
For Each rCell2 In Sheet2.Range("A1:A100")
If rCell2.EntireRow.Hidden = False And rCell2.Row lPasteRow
Then
lPasteRow = rCell2.Row
rCell2.PasteSpecial
Application.ScreenUpdating = False
End If
Next rCell2
Next rCell
End Sub



--
Regards
Dave Hawley
www.ozgrid.com
"rk0909" wrote in message
...
All,

I want to copy say 10 rows and then paste into another 10 rows. Problem is
the destination rows are not contiguous. there are 4-5 rows in between
each
of these rows which are grouped.

is there a way to do that. I tried the visible cells property but that
does
not work.

Any help of direction is much appreciated.

thanks much,

RK



ozgrid.com

copy rows and paste onto visible only
 
Oops "Application.ScreenUpdating = False"

Should be;
Application.CutCopyMode=False



--
Regards
Dave Hawley
www.ozgrid.com
"ozgrid.com" wrote in message
...
Something like;

Sub CopyToVisibleRows()
Dim rCell As Range, rCell2 As Range
Dim lPasteRow As Long

lPasteRow = 1
For Each rCell In Sheet1.Range("A1:A10")
rCell.EntireRow.Copy
For Each rCell2 In Sheet2.Range("A1:A100")
If rCell2.EntireRow.Hidden = False And rCell2.Row lPasteRow
Then
lPasteRow = rCell2.Row
rCell2.PasteSpecial
Application.ScreenUpdating = False
End If
Next rCell2
Next rCell
End Sub



--
Regards
Dave Hawley
www.ozgrid.com
"rk0909" wrote in message
...
All,

I want to copy say 10 rows and then paste into another 10 rows. Problem
is
the destination rows are not contiguous. there are 4-5 rows in between
each
of these rows which are grouped.

is there a way to do that. I tried the visible cells property but that
does
not work.

Any help of direction is much appreciated.

thanks much,

RK





All times are GMT +1. The time now is 12:14 PM.

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