ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   what is the vb code to copy rows from one sheet to another? (https://www.excelbanter.com/excel-discussion-misc-queries/90601-what-vbulletin-code-copy-rows-one-sheet-another.html)

bxc2739

what is the vb code to copy rows from one sheet to another?
 

Can someone please help tell me what is the correct syntax/ie vb code
to copy a entire row from one sheet to another?

Pretend I have two sheets and want to copy an entire row from sheet2
to sheet one , what is the code to do something like this?

I know I can do it manually, but for what I am doing I need
the macro code to do it automatically.

Thanks


--
bxc2739
------------------------------------------------------------------------
bxc2739's Profile: http://www.excelforum.com/member.php...o&userid=32538
View this thread: http://www.excelforum.com/showthread...hreadid=545604


Ardus Petus

what is the vb code to copy rows from one sheet to another?
 
If you cant to copy everything (including formats):

Worksheets("Sheet2").Rows(10).Copy _
dest:=Worksheets("Sheet1").rows(10)

To copy values only:
Worksheets("Sheet1").rows(10).value = _
Worksheets("Sheet2").Rows(10).Value

HTH
--
AP

"bxc2739" a écrit
dans le message de news:
...

Can someone please help tell me what is the correct syntax/ie vb code
to copy a entire row from one sheet to another?

Pretend I have two sheets and want to copy an entire row from sheet2
to sheet one , what is the code to do something like this?

I know I can do it manually, but for what I am doing I need
the macro code to do it automatically.

Thanks


--
bxc2739
------------------------------------------------------------------------
bxc2739's Profile:
http://www.excelforum.com/member.php...o&userid=32538
View this thread: http://www.excelforum.com/showthread...hreadid=545604




Dave Peterson

what is the vb code to copy rows from one sheet to another?
 
You gonna be pasting at the bottom of a group of rows???

Can you pick out a column that has data in it if that row is used?

dim myCell as range
dim NextRow as long
dim DestCell as range

with worksheets("sheet1")
set mycell = .range("b72") 'some cell
end with

with worksheets("sheet2")
nextrow = .cells(.rows.count,"G").end(xlup).row + 1
set destcell = .cells(nextrow,"A")
end with

mycell.entirerow.copy _
destination:=destcell



bxc2739 wrote:

Can someone please help tell me what is the correct syntax/ie vb code
to copy a entire row from one sheet to another?

Pretend I have two sheets and want to copy an entire row from sheet2
to sheet one , what is the code to do something like this?

I know I can do it manually, but for what I am doing I need
the macro code to do it automatically.

Thanks

--
bxc2739
------------------------------------------------------------------------
bxc2739's Profile: http://www.excelforum.com/member.php...o&userid=32538
View this thread: http://www.excelforum.com/showthread...hreadid=545604


--

Dave Peterson


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

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