+ Reply to Thread
Results 1 to 7 of 7

Range for activecell.offset

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Range for activecell.offset

    I normally use the following statement to copy the second cell located to the right of the found cell back into the original worksheet:

    Please Login or Register  to view this content.
    The above works fine. However I would like to use a range instead, i.e.I would like to copy the second, third and fourth cell located to the right of the found cell. I used the following:

    Please Login or Register  to view this content.
    However the above does exactly the same as the first macro? Any ideas why?

    PS: what should I use to copy and paste the 2nd, 3rd and 5th cells to the right in one go?

    Thanks,
    Antoine
    Attached Files Attached Files
    Last edited by Folshot; 05-10-2011 at 04:35 AM. Reason: SOLVED

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Range for activecell.offset

    Antoine,

    Instead of these two lines:
    Please Login or Register  to view this content.

    Use this line:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  3. #3
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Range for activecell.offset

    Thanks a lot tigeravatar, it works great.

    Would you know how to combine a range + a single cell? For example, I would like to copy the 2nd, 3rd and 5th cell located to the right of the found cell.

    Thanks again,
    Antoine

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Range for activecell.offset

    You can use the Application Union method to build up a union of ranges, eg:
    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  5. #5
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Range for activecell.offset

    Hi Colin,

    It does help as well, thanks. However my final spreadsheet has around 70 columns, hence I was wondering if it was possible to combine ranges and single columns (i.e. column 12 to 34 with columns 57 and 68) rather than having to enter each column individually.

    Antoine

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Range for activecell.offset

    Antoine,

    You can do that with the following:

    Please Login or Register  to view this content.


    Notes:
    -Use ":" to combine two cells into a solid range
    -Use "," to add a new (separate) group to the range
    -The way I have it formatted is optional. It makes it easier for me to see which groups are in the range quickly if each group is on its own line. You'll notice the offset(0,5) doesn't have a combiner ":" because that cell is by itself.

    Hope this helps,
    ~tigeravatar

  7. #7
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Range for activecell.offset

    Thanks a lot tigeravatar, it works perfectly, exactly what I was looking for.

+ 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