+ Reply to Thread
Results 1 to 6 of 6

Copy via code from a dynamic range using offeset

  1. #1
    Greg
    Guest

    Copy via code from a dynamic range using offeset

    Hi out there,

    Can someone help me with the syntax to refer to a dynamic range via
    code?

    I am trying to use activesheet with the following parameters:

    - Start copy at cell CI6 (including CI6)
    - Go down rows via value in cell CI2
    - Past values to cell G6


    TIA,

    Greg


  2. #2
    Tom Ogilvy
    Guest

    Re: Copy via code from a dynamic range using offeset

    Range("CI6").Resize(Range("CI2"),1).Copy Destination:=Range("G6")

    --
    Regards,
    Tom Ogilvy

    "Greg" <[email protected]> wrote in message
    news:[email protected]...
    > Hi out there,
    >
    > Can someone help me with the syntax to refer to a dynamic range via
    > code?
    >
    > I am trying to use activesheet with the following parameters:
    >
    > - Start copy at cell CI6 (including CI6)
    > - Go down rows via value in cell CI2
    > - Past values to cell G6
    >
    >
    > TIA,
    >
    > Greg
    >




  3. #3
    Greg
    Guest

    Re: Copy via code from a dynamic range using offeset

    Thanks Tom,

    When I use your code as follows:

    ThisWorkbook.ActiveSheet.Range("CI6").Resize(Range("CI2=AD"), 1).Copy
    Destination:=3DRange("G6")


    I get a "Method Range Of Object _Global Failed.

    do I have a typo somewhere?

    Greg


  4. #4
    Greg
    Guest

    Re: Copy via code from a dynamic range using offeset

    Tom,

    Thanks for the quick reply and help. Disregard my e-mail about it not
    working.

    For some reason when I copied it out of Google Groups and into the VB
    editor it did not come over right. I did not notice this till after
    posting the 2nd question. I found the typo error and fixed and it is
    working great!!

    Greg


  5. #5
    Greg
    Guest

    Re: Copy via code from a dynamic range using offeset

    Sorry - me again.

    I noticed that it is pasting cell contents versus values. How would I
    keep the code in the simple one line and have it past values?

    I guess I could split it to a copy and then a pastvalues line, but I
    like it in one command.

    Thanks again.


  6. #6
    Tom Ogilvy
    Guest

    Re: Copy via code from a dynamic range using offeset

    Pastespecial is a separate command.

    Range("CI6").Resize(Range("CI2"),1).Copy
    Range("G6").Pastespecial xlvalues

    you could use

    Range("G6").Resize(Range("CI2"),1).Value =
    Range("CI6").Resize(Range("CI2"),1).Value

    which is one line.

    --
    Regards,
    Tom Ogilvy

    "Greg" <[email protected]> wrote in message
    news:[email protected]...
    > Sorry - me again.
    >
    > I noticed that it is pasting cell contents versus values. How would I
    > keep the code in the simple one line and have it past values?
    >
    > I guess I could split it to a copy and then a pastvalues line, but I
    > like it in one command.
    >
    > Thanks again.
    >




+ 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