Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select first worksheet

Status
Not open for further replies.

osx99

Technical User
Apr 9, 2003
250
GB
I have several workbooks in excel that I have to open and extract data with a macro

I am extracting data from the first worksheet but the code stalls when it opens a workbook that has been saved with another worksheet visible (I.e opens on the second or third worksheet visible)

What is the code to always select the first cell on the first worksheet regardless of how it has been saved? The worksheets may have different names but I always need the first (leftmost one)

Many thanks
Os
 
What about something like this ?
ActiveWorkbook.Worksheets(1).Cells(1, 1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for pointing me in the right direction,I had to use

ActiveWorkbook.Worksheets(1).select
 
You can select a certain cell using the below command and changing the cell name:

ActiveWorkbook.Worksheets(1).Range("A1").Select
 




bdmangum,

I would avoid using the Select and Activate methods as much as possible.

It is NOT a good practice!

Skip,

[glasses] [red][/red]
[tongue]
 
I agree Skip. I avoid using those methods whenever possible. However, osx99's goal was to select cell A1 upon opening of the file. Depending on why he wants to do this would determine whether or not this is one of the rare occasions to use the Select method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top