Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 6 of 6

Thread: Select Vs Activate: When to use which?

  1. #1
    Join Date
    28th February 2005
    Posts
    95

    Select Vs Activate: When to use which?

    1. What's the difference between:
    VB:
    Worksheets("Sheet1").Range("A5").Select 
    
    
    and
    VB:
    Worksheets("Sheet1").Range("A5").Activate 
    
    
    ?

    2. Can I use a Selection. method with an object 'selected' using .Activate in the preceding code line?

    3. Say I am currently on Sheet2, Cell A5. When I click the macro button, I want Excel to copy the value from Sheet1, Cell A5 and paste it into Sheet2, Cell A5. But I do NOT want the screen display to actually jump from Sheet2 to Sheet1, and then back to Sheet2. So do I need to use .Activate, or .Select, to copy the value of Sheet1, Cell A5?
    Last edited by Om Avataar; April 6th, 2007 at 19:50.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: Select Vs Activate: When to use which?

    in terms of cells help says

    Remarks
    To select a cell or a range of cells, use the Select method. To make a single cell the active cell, use the Activate method.
    But normal selection is not required. So in answer to question 3,
    VB:
    Sub Macro1() 
         
        Worksheets("Sheet1").Range("A5").Copy Worksheets("Sheet2").Range("A5") 
         
    End Sub 
    
    

    Cheers
    Andy


  3. #3
    Join Date
    28th February 2005
    Posts
    95

    Re: Select Vs Activate: When to use which?

    Thanks, Andy... Appreciate it

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    25th January 2003
    Location
    UK
    Posts
    2,745

    Re: Select Vs Activate: When to use which?

    Hi,

    Have you looked at the VBE Help for details on each of the methods?

    Having said that, you will generally find that your code runs much better by using neither method. It is rarely necessary to either Select or Activate an object in order to work with it. In fact, doing so just makes your code slower.

    For example, using your objective of copying, if we used the Macro Recorder we would get the following code:
    VB:
    Sub Macro1() 
         '
         ' Macro1 Macro
         ' Macro recorded 06/04/2007 by Richie
         '
         
         '
        Sheets("Sheet1").Select 
        Range("A5").Select 
        Selection.Copy 
        Sheets("Sheet2").Select 
        ActiveSheet.Paste 
    End Sub 
    
    
    However, we could obtain the same objective by removing the Select elements of the code (and specifying the destination argument). Like this:
    VB:
    Sub Macro2() 
        Sheets("Sheet1").Range("A5").Copy Destination:=Sheets("Sheet2").Range("A5") 
    End Sub 
    
    
    Does that help?
    Cross-poster? Read this: Cross-posters
    Struggling to use tags (including Code tags)? : Forum tags

  5. #5
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Select Vs Activate: When to use which?

    Don't use either - they aren't normally needed.

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    12th July 2012
    Posts
    1

    Re: Select Vs Activate: When to use which?

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Calendar Control To Activate/Select Sheets
    By lancemmx in forum EXCEL HELP
    Replies: 4
    Last Post: August 17th, 2008, 16:41
  2. Select/Activate Sheet Where Name Resides In Cell
    By Sagaram in forum EXCEL HELP
    Replies: 5
    Last Post: April 27th, 2008, 11:37
  3. Replies: 5
    Last Post: March 24th, 2006, 06:06
  4. Sheet1.Activate vs Sheet1.Select
    By mikeburg in forum EXCEL HELP
    Replies: 5
    Last Post: October 13th, 2005, 11:29
  5. Select and activate first blank cell
    By rirstress in forum EXCEL HELP
    Replies: 3
    Last Post: May 30th, 2003, 09:25

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
  •  
porno