PC Review


Reply
Thread Tools Rate Thread

copy rows to sheet 2

 
 
=?Utf-8?B?R0J2ZEg=?=
Guest
Posts: n/a
 
      26th Feb 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      26th Feb 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy rows from one Data sheet to another sheet based on cell conte John McKeon Microsoft Excel Misc 2 15th May 2010 06:49 AM
copy rows to other sheet Carpe Diem Microsoft Excel Worksheet Functions 3 17th Dec 2007 06:58 PM
Copy rows onto existing sheet / start a new sheet if full mg_sv_r Microsoft Excel Programming 0 29th Nov 2007 12:57 PM
Search for rows in one sheet and copy into another sheet based on customer id chitiksha@gmail.com Microsoft Excel Worksheet Functions 1 22nd Oct 2007 03:09 AM
Help: auto-copy entire rows from 1 sheet (based on cell criteria) to another sheet. bertbarndoor Microsoft Excel Programming 4 5th Oct 2007 04:00 PM


Features
 

Advertising
 

Newsgroups
 


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