+ Reply to Thread
Results 1 to 3 of 3

Thread: Copy a range of generic cells.

  1. #1
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,274

    Thumbs up Copy a range of generic cells.

    Hi all, I will give you the code first and then the problem.

    Application.Worksheets(1).Select
    ActiveCell.End(xlToRight).Select
    ActiveCell.Offset(0,-24).Select
    The problem I'm having is I need to copy the last 24 months of data. I can run a Do While Loop to run from 24 months ago until now but with just short of 1000 cells to copy, the loop not only takes a while, but I feel like I might have a siezure watching the copy and paste process. Is there a way to select all the cells at once, from the last cell in the row to the cell at position -24?

    If more is needed, I'll try to accommodate.

    Thank you.
    Last edited by Mordred; 07-20-2010 at 02:02 PM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Copy a range of generic cells.

    To grab all cells at once:
    Activecell.End(xlToRight).Offset(,-23).Resize(,24).Copy


    To reduce risk of siezures:
    Application.ScreenUpdating = False
    
    ....code
    ....code
    ....code
    
    Application.ScreenUpdating = True
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Forum Guru Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,274

    Re: Copy a range of generic cells.

    Thank you JBeaucaire, it worked like a charm. And thank you for reducing my risk of siezure

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0