Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy rows to sheet 2

Hello,

I am new to (VBA) programming so my question is most likely fairly simple.
In my table cell B3 contains the row number that it is all about, I would
like the row indicated in cell B3 and the row before that copied to sheet2
(so if B3 = 43 I would like to have row 42 and 43 copied to sheet 2). On
sheet2 these two rows should be placed on row 2 and 3 starting at column A.
Hope my question is clear, if not please ask me for further information.

Barry

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default copy rows to sheet 2

Sub copydata()
Dim rw as Long
rw = Range("B3").Value - 1
if rw 0 and rw < 65536 then
rows(rw).Resize(2).copy
worksheets("Sheet2").Rows(2).PasteSpecial xlValues
end if
End Sub

change xlValues to xlAll if you want all formatting and formulas.

--
Regards,
Tom Ogilvy


"GBvdH" wrote:

Hello,

I am new to (VBA) programming so my question is most likely fairly simple.
In my table cell B3 contains the row number that it is all about, I would
like the row indicated in cell B3 and the row before that copied to sheet2
(so if B3 = 43 I would like to have row 42 and 43 copied to sheet 2). On
sheet2 these two rows should be placed on row 2 and 3 starting at column A.
Hope my question is clear, if not please ask me for further information.

Barry

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy rows from one Data sheet to another sheet based on cell conte John McKeon Excel Discussion (Misc queries) 2 May 15th 10 06:49 AM
copy matching value rows to other sheet tkraju via OfficeKB.com Excel Discussion (Misc queries) 2 June 7th 09 12:41 PM
copy rows to other sheet Carpe Diem Excel Worksheet Functions 3 December 17th 07 06:58 PM
Search for rows in one sheet and copy into another sheet based on customer id [email protected] Excel Worksheet Functions 1 October 22nd 07 03:09 AM
Select rows and copy to another sheet. Juan Excel Programming 6 March 29th 05 12:53 AM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"