Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Help with Selecting a Cell on a different Sheet

  Asked By: Loretta    Date: Oct 26    Category: MS Office    Views: 1170
  

I am having trouble selecting a cell on a different sheet. If Sheet
1 is active and I need to select a cell on Sheet 2 i assumed that by
qualifying the cell on Sheet 2 VBA would automatically go to the
cell. Is this not correct?

This does not work:

Sub TryA1()

Worksheets("Sheet1").Range("Q2").Select
Workbooks("BOOK1").Worksheets("Sheet2").Range("A1").Select

End Sub

This does work:

Sub TryA2()

Worksheets("Sheet1").Range("Q2").Select
Worksheets("Sheet2").Activate
Worksheets("Sheet2").Range("A1").Select

End Sub

If the range address is qualified why is it necessary to activate
Sheet 2 first?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Grady Stewart     Answered On: Oct 26

Probably because you're trying to select, as opposed to doing
something else to it, such as copying to it or changing its format or
changing its value.

 
Answer #2    Answered By: Brendan Smith     Answered On: Oct 26

No idea of the "why", but you are correct.

See also
msdn.microsoft.com/.../xl\
howSelectingandactivatingcells1_HV05204866.asp for Microsoft's words on the
subject.

 
Answer #3    Answered By: Faiza Mian     Answered On: Oct 26

Thank you for your reply and your research. This was very helpful
and helped me learn a lot.

 
Didn't find what you were looking for? Find more on Help with Selecting a Cell on a different Sheet Or get search suggestion and latest updates.




Tagged: