ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/Paste (https://www.excelbanter.com/excel-programming/317440-copy-paste.html)

scrabtree23[_3_]

Copy/Paste
 
The following code has worked good for me in the past:

Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("Old Data").Range("A1")
Sheets("Old Data").Range("A1").EntireRow.Delete Shift:=xlUp

However, I now want it to "Insert the Copied Data" at the destination and
shift the existing data down.

The code currently allows the data to be pasted over any existing data???

Don Guillett[_4_]

Copy/Paste
 
try

with worksheets("Old Data")
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy .Range("A" & .cells(rows.count,"a").end(xlup).row+1)
end with

--
Don Guillett
SalesAid Software

"scrabtree23" wrote in message
...
The following code has worked good for me in the past:

Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("Old Data").Range("A1")
Sheets("Old Data").Range("A1").EntireRow.Delete Shift:=xlUp

However, I now want it to "Insert the Copied Data" at the destination and
shift the existing data down.

The code currently allows the data to be pasted over any existing data???




JE McGimpsey

Copy/Paste
 
One way:

Dim rng As Range
Dim nRows As Long
Set rng = ActiveSheet.AutoFilter.Range
nRows = rng.Columns(1).SpecialCells(xlCellTypeVisible).Cou nt
With Worksheets("Old Data")
.Range("A1").Resize(nRows).EntireRow.Insert Shift:=xlDown
rng.Copy Destination:=.Range("A1")
.Range("A1").EntireRow.Delete
End With

In article ,
"scrabtree23" wrote:

The following code has worked good for me in the past:

Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("Old Data").Range("A1")
Sheets("Old Data").Range("A1").EntireRow.Delete Shift:=xlUp

However, I now want it to "Insert the Copied Data" at the destination and
shift the existing data down.

The code currently allows the data to be pasted over any existing data???


JE McGimpsey

Copy/Paste
 
That'll put the data (plus the headers) at the bottom of the range. If I
read correctly, the OP wanted a way to shift existing data down instead.

In article ,
"Don Guillett" wrote:

with worksheets("Old Data")
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy .Range("A" & .cells(rows.count,"a").end(xlup).row+1)
end with



All times are GMT +1. The time now is 11:38 PM.

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