beginner999
Programmer
how can i delete the rows after pasting the data. Please help me
for example if i pasted
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
then I need to delete first row and then i paste same range
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1
here i need to delete 2 rows from what ever i pasted. then finally it looks like this
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
c 1 1 1 1 --- 3rd row
so far my code is like this
r = ActiveCell.CurrentRegion.Rows.Count
lastrow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
UsedRange.Select
Selection.Copy
For i = 1 To r
ActiveCell.Offset(lastrow + 1, 0).Select
ActiveSheet.Paste
Next i
for example if i pasted
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
then I need to delete first row and then i paste same range
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1
here i need to delete 2 rows from what ever i pasted. then finally it looks like this
a 1 2 3 4 --- this is the row in excel with 5 cells
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
b 7 8 9 1 --- 2nd row
c 1 1 1 1 --- 3rd row
empty row
c 1 1 1 1 --- 3rd row
so far my code is like this
r = ActiveCell.CurrentRegion.Rows.Count
lastrow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
UsedRange.Select
Selection.Copy
For i = 1 To r
ActiveCell.Offset(lastrow + 1, 0).Select
ActiveSheet.Paste
Next i