Copy & paste row in anther worksheet

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

how to copy & paste and Cut & paste data row from one worksheet or another
one worksheet??

The requirement is I need to create a new worksheet first, and the copy &
paste or cut & paste a data row from one exist worksheet to the newly
created worksheet.

because i am a novice in writing VBA in Excel , pls help
 
The easiest way to learn this kind of stuff is to record a macro when you do it
manually.

In fact, record two while you try both options.

I like to add the worksheet first, then do the cut/copy, then paste.

Sometimes, there are things that make xl lose the the cut/copy information and I
find it's safer to put the cut/copy close together in the code.

And after you record the macro, take a look at the code. Excel records all your
selects and activates. You can clean it up and it may look a little like:

option explicit
sub testme01()

dim newwks as worksheet
dim curwks as worksheet
dim rngtocopy as range
dim destcell as range

set curwks = worksheets("sheet1")
set newwks = worksheets.add

with curwks
set rngtocopy = .range("a15").entirerow
end with

with newwks
set destcell = .range("a1")
end with

rngtocopy.copy _
destination:=destcell

application.cutcopymode = false

end sub
 
Back
Top