+ Reply to Thread
Results 1 to 5 of 5

Conditional select and paste

  1. #1
    Registered User
    Join Date
    11-25-2005
    Posts
    27

    [Solved] Conditional select and paste

    I have a range of data (C4:K6) named Data_1. I would like to create code that will go through this range (or any defined range) and copy the first two rows of this data to two different rows on the sheet (let's say these rows are defined by the range C85:K86 and named Data_1_1st_2rows). However, I don't just need the data pasted to this range. I need the entire frist two rows of Data_1 pasted into the rows comprising Data_1_1st_2rows. Thanks.
    Last edited by BrianDP1977; 12-05-2005 at 08:15 PM.

  2. #2
    Greg Wilson
    Guest

    RE: Conditional select and paste

    Try:

    Sub TransferData()
    Dim r1 As Range, r2 As Range
    Set r1 = Range("Data_1").Resize(2, Columns.Count)
    Set r2 = Range("Data_1_1st_2Rows").Resize(2, Columns.Count)
    r2.Value = r1.Value
    End Sub

    Regards,
    Greg

    "BrianDP1977" wrote:

    >
    > I have a range of data (C4:K6) named Data_1. I would like to create code
    > that will go through this range (or any defined range) and copy the
    > first two rows of this data to two different rows on the sheet (let's
    > say these rows are defined by the range C85:K86 and named
    > Data_1_1st_2rows). However, I don't just need the data pasted to this
    > range. I need the entire frist two rows of Data_1 pasted into the rows
    > comprising Data_1_1st_2rows. Thanks.
    >
    >
    > --
    > BrianDP1977
    > ------------------------------------------------------------------------
    > BrianDP1977's Profile: http://www.excelforum.com/member.php...o&userid=29110
    > View this thread: http://www.excelforum.com/showthread...hreadid=490366
    >
    >


  3. #3
    Registered User
    Join Date
    11-25-2005
    Posts
    27
    Doesn't seem to work. Here's how I have it posted:

    Please Login or Register  to view this content.
    I get a application or object-defined error

  4. #4
    Greg Wilson
    Guest

    Re: Conditional select and paste

    Sorry, I misread the range definitions. Try:

    Sub TransferData()
    Dim r1 As Range, r2 As Range
    Set r1 = Range("Data_1").Resize(2).EntireRow
    Set r2 = Range("Data_1_1st_2Rows").EntireRow
    r2.Value = r1.Value
    End Sub

    Regards,
    Greg



  5. #5
    Registered User
    Join Date
    11-25-2005
    Posts
    27
    That works great. Thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1