From: Makelei on
Hi,
XP and Excel2003.

What might be the reason why this is not working (Sheet2 is codename):
Sheet2.Select

I have tried all possibilities that I can imaging, but no. I have another
file and selecting sheet with code name (Sheet4.Select) funtions just fine.

Now using code:
Workbooks.Open Filename:=Doc2
ActiveWorkbook.Sheet2.Select

Opens Doc2 excel file just fine, but does not open the sheet.

Thanks in advance
MakeLei
From: Jacob Skaria on
Use the index number instead.
Activeworkbook.Sheets(2).select

OR the sheetname itself

Activeworkbook.Sheets("Sheetname").select

--
Jacob (MVP - Excel)


"Makelei" wrote:

> Hi,
> XP and Excel2003.
>
> What might be the reason why this is not working (Sheet2 is codename):
> Sheet2.Select
>
> I have tried all possibilities that I can imaging, but no. I have another
> file and selecting sheet with code name (Sheet4.Select) funtions just fine.
>
> Now using code:
> Workbooks.Open Filename:=Doc2
> ActiveWorkbook.Sheet2.Select
>
> Opens Doc2 excel file just fine, but does not open the sheet.
>
> Thanks in advance
> MakeLei
From: Bob Phillips on
Just use

Workbooks.Open Filename:=Doc2
Sheet2.Select

the newly opened workbook will be the active book.

--

HTH

Bob

"Makelei" <Makelei(a)discussions.microsoft.com> wrote in message
news:66F8E17A-939C-43FA-A391-6FF603483867(a)microsoft.com...
> Hi,
> XP and Excel2003.
>
> What might be the reason why this is not working (Sheet2 is codename):
> Sheet2.Select
>
> I have tried all possibilities that I can imaging, but no. I have another
> file and selecting sheet with code name (Sheet4.Select) funtions just
> fine.
>
> Now using code:
> Workbooks.Open Filename:=Doc2
> ActiveWorkbook.Sheet2.Select
>
> Opens Doc2 excel file just fine, but does not open the sheet.
>
> Thanks in advance
> MakeLei


From: Jacob Skaria on
Oops...I missed the boat completely...

Try (if trusted access to Visual Basic Projects is turned ON)

Activeworkbook.VBProject.VBComponents("Sheet1").Activate

OR

Dim ws As Worksheet, strSheetCodeName As String
strSheetCodeName = "Sheet1"
For Each ws In Worksheets
If ws.CodeName = strSheetCodeName Then ws.Select: Exit For
Next

--
Jacob (MVP - Excel)


"Jacob Skaria" wrote:

> Use the index number instead.
> Activeworkbook.Sheets(2).select
>
> OR the sheetname itself
>
> Activeworkbook.Sheets("Sheetname").select
>
> --
> Jacob (MVP - Excel)
>
>
> "Makelei" wrote:
>
> > Hi,
> > XP and Excel2003.
> >
> > What might be the reason why this is not working (Sheet2 is codename):
> > Sheet2.Select
> >
> > I have tried all possibilities that I can imaging, but no. I have another
> > file and selecting sheet with code name (Sheet4.Select) funtions just fine.
> >
> > Now using code:
> > Workbooks.Open Filename:=Doc2
> > ActiveWorkbook.Sheet2.Select
> >
> > Opens Doc2 excel file just fine, but does not open the sheet.
> >
> > Thanks in advance
> > MakeLei
From: Ron Rosenfeld on
On Tue, 1 Jun 2010 04:32:02 -0700, Makelei
<Makelei(a)discussions.microsoft.com> wrote:

>Hi,
>XP and Excel2003.
>
>What might be the reason why this is not working (Sheet2 is codename):
>Sheet2.Select
>
>I have tried all possibilities that I can imaging, but no. I have another
>file and selecting sheet with code name (Sheet4.Select) funtions just fine.
>
>Now using code:
> Workbooks.Open Filename:=Doc2
> ActiveWorkbook.Sheet2.Select
>
>Opens Doc2 excel file just fine, but does not open the sheet.
>
>Thanks in advance
>MakeLei

Probably because ActiveWorkbook<>Doc2

Maybe something like:

Workbooks(Doc2).Worksheets("Sheet2").Activate