+ Reply to Thread
Results 1 to 6 of 6

Avoiding Range("A1").Select

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Avoiding Range("A1").Select

    Some discussion in the "General" part of the Forum suggested that it is rarely neccessary to use Worksheet.Select or Range.Select. I can see why as it slows everything down and causes screen jumps. But how do I do it?

    The bit of code below refreshes 2 queries in Sheet("Material_Calcs"). It then copies the dyamic table of the first query to "Raw_Materials and then appends the resuts of the second query to the table in "Raw_Materials.
    How do I avoid all the sheet and range selections?

    Please Login or Register  to view this content.
    John
    Last edited by j_Southern; 01-21-2011 at 06:22 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Avoiding Range("A1").Select

    You can normally condense the .Select and Selection parts.

    Please Login or Register  to view this content.
    If you are using simple copy/paste you can specify the paste location on the copy command.

    Please Login or Register  to view this content.
    I assume the non use of the variable 'y' is just a typo.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Avoiding Range("A1").Select

    As far as screen jumping and slowing down is concerned, another great method, aside form limiting the use of .select, is to turn off screen updating.

    Example:
    Please Login or Register  to view this content.
    This prevents the screen from refreshing at every little change and really speeds things up. Just remember to turn screen updating back on when you are done, otherwise the user may think that the workbook is frozen when it really is not.

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Avoiding Range("A1").Select

    Andy,
    Thanks very much for your interest. I have tried your code and it works well noticeably increasing speed. I see the approach now
    Am I right in assuming that when you refer to simple copy/paste you mean as distinct from PastSpecial, PasteFormulae etc?
    The y variable is used further down the code. The John on the end of False is the typo! just checking
    John

  5. #5
    Registered User
    Join Date
    12-24-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Avoiding Range("A1").Select

    Whizbang
    I had not seen your contribution when I last replied. I can confirm that added to Andy Popes helpnit has speeded me up a treat.
    I shall mark as solved. Thank you everybody for your help
    John

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Avoiding Range("A1").Select

    Yes if you need any of the pastespecials then 2 lines of code are required.

+ 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