+ Reply to Thread
Results 1 to 4 of 4

Paste ranges with offset Excel 2000

  1. #1
    carloshernandezy
    Guest

    Paste ranges with offset Excel 2000

    Hello,

    I=A8m working with copyinf and pasting cell in differents sheets, and
    ait works well but when I try to do the same with range I have
    problems.

    I use this code.
    -------------------------------
    Range("B2").Select
    Do
    If IsEmpty(ActiveCell) =3D False Then
    ActiveCell.Offset(1, 0).Select
    End If
    Loop Until IsEmpty(ActiveCell) =3D True
    ActiveCell.Value =3D
    Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")

    ActiveCell.Offset(0, -1) =3D _
    Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")
    ____________________________________

    the same code refering only to one cell works well, I think the problem
    is the Offset, can I change it??.

    Thanks in advance.


  2. #2
    Blue Aardvark
    Guest

    RE: Paste ranges with offset Excel 2000

    The problem with these lines is that you are trying to set one cell (the
    active cell) equal to 3 cells (D13:D15).

    > ActiveCell.Value =
    > Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")
    > ActiveCell.Offset(0, -1) = _
    > Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")


    If you wanted to put the 3 cells at the bottom of the list, then you could
    use

    ActiveCell.RANGE("A1:A3").Value =
    Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15").VALUE

    This would place the cells D13:D15 into the active cell and the 2 cells
    below it (the A1:A3 bit is relative to the activeCell)

  3. #3
    Bob Phillips
    Guest

    Re: Paste ranges with offset Excel 2000

    I can't see any problems with the code (apart from testing for blank at the
    start of the loop in case B2 is empty), but this is a more efficient way of
    doing it

    With Range("B2").End(xlDown).Offset(1, 0)
    .Value = Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")
    .Offset(0, -1) = _
    Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")
    End With


    --
    HTH

    Bob Phillips

    "carloshernandezy" <[email protected]> wrote in message
    news:[email protected]...
    Hello,

    I¨m working with copyinf and pasting cell in differents sheets, and
    ait works well but when I try to do the same with range I have
    problems.

    I use this code.
    -------------------------------
    Range("B2").Select
    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    End If
    Loop Until IsEmpty(ActiveCell) = True
    ActiveCell.Value =
    Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")

    ActiveCell.Offset(0, -1) = _
    Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")
    ____________________________________

    the same code refering only to one cell works well, I think the problem
    is the Offset, can I change it??.

    Thanks in advance.



  4. #4
    Bob Phillips
    Guest

    Re: Paste ranges with offset Excel 2000

    Oops, missed the treble cell bit (I commented it out in my tests).

    That as well, the approach is more efficient.

    --
    HTH

    Bob Phillips

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > I can't see any problems with the code (apart from testing for blank at

    the
    > start of the loop in case B2 is empty), but this is a more efficient way

    of
    > doing it
    >
    > With Range("B2").End(xlDown).Offset(1, 0)
    > .Value = Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")
    > .Offset(0, -1) = _
    > Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")
    > End With
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "carloshernandezy" <[email protected]> wrote in message
    > news:[email protected]...
    > Hello,
    >
    > I¨m working with copyinf and pasting cell in differents sheets, and
    > ait works well but when I try to do the same with range I have
    > problems.
    >
    > I use this code.
    > -------------------------------
    > Range("B2").Select
    > Do
    > If IsEmpty(ActiveCell) = False Then
    > ActiveCell.Offset(1, 0).Select
    > End If
    > Loop Until IsEmpty(ActiveCell) = True
    > ActiveCell.Value =
    > Workbooks("ReportRP.xls").Sheets("PS").Range("D13:D15")
    >
    > ActiveCell.Offset(0, -1) = _
    > Workbooks("ReportRP.xls").Sheets("PS").Range("I6:I10")
    > ____________________________________
    >
    > the same code refering only to one cell works well, I think the problem
    > is the Offset, can I change it??.
    >
    > Thanks in advance.
    >
    >




+ 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