Problem with "Application.Goto Reference" code line

In my Workbook_Open() subroutine, I run the following line of code:

Application.Goto Reference:=Sheets("Sheet1").Range("A1"), scroll:=True

This code works okay, but whenever I mark my "Sheet1" as hidden, the
code no longer works.  The error message that I get is Run-Time
Error 1004 - Method 'Goto' of Object '_Application' Failed.

Is there any way to use that line of code on a hidden sheet??

thanx


0
Robert
11/28/2009 5:17:11 PM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
3791 Views

Similar Articles

[PageSpeed] 37

The sheet needs to be visible for that code to work.


"Robert Crandal" <nobody@gmail.com> wrote in message 
news:sWcQm.5960$y%5.4997@newsfe03.iad...
> In my Workbook_Open() subroutine, I run the following line of code:
>
> Application.Goto Reference:=Sheets("Sheet1").Range("A1"), scroll:=True
>
> This code works okay, but whenever I mark my "Sheet1" as hidden, the
> code no longer works.  The error message that I get is Run-Time
> Error 1004 - Method 'Goto' of Object '_Application' Failed.
>
> Is there any way to use that line of code on a hidden sheet??
>
> thanx
>
> 


0
JLGWhiz
11/28/2009 5:19:39 PM
Dim myCell as range
set mycell = worksheets("sheet1").range("A1")

mycell.parent.visible = xlsheetvisible
application.goto reference:=mycell, scroll:=true

Just unhide the sheet yourself.  If the sheet is already visible, then the
..visible line won't cause trouble.  
(If the workbook's structure is protected, you will get an error, though.)

Robert Crandal wrote:
> 
> In my Workbook_Open() subroutine, I run the following line of code:
> 
> Application.Goto Reference:=Sheets("Sheet1").Range("A1"), scroll:=True
> 
> This code works okay, but whenever I mark my "Sheet1" as hidden, the
> code no longer works.  The error message that I get is Run-Time
> Error 1004 - Method 'Goto' of Object '_Application' Failed.
> 
> Is there any way to use that line of code on a hidden sheet??
> 
> thanx

-- 

Dave Peterson
0
Dave
11/28/2009 5:46:10 PM
So, to set the sheet as hidden again, would I use the following
line:

mycell.parent.visible = xlSheetHidden     '   ???



"Dave Peterson" <petersod@verizonXSPAM.net> wrote in message 
news:4B1161E2.51363332@verizonXSPAM.net...
> Dim myCell as range
> set mycell = worksheets("sheet1").range("A1")
>
> mycell.parent.visible = xlsheetvisible
> application.goto reference:=mycell, scroll:=true
>
> Just unhide the sheet yourself.  If the sheet is already visible, then the
> .visible line won't cause trouble.
> (If the workbook's structure is protected, you will get an error, though.)
>

0
Robert
11/28/2009 6:24:24 PM
Sounds like it's worth testing!

Robert Crandal wrote:
> 
> So, to set the sheet as hidden again, would I use the following
> line:
> 
> mycell.parent.visible = xlSheetHidden     '   ???
> 
> "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
> news:4B1161E2.51363332@verizonXSPAM.net...
> > Dim myCell as range
> > set mycell = worksheets("sheet1").range("A1")
> >
> > mycell.parent.visible = xlsheetvisible
> > application.goto reference:=mycell, scroll:=true
> >
> > Just unhide the sheet yourself.  If the sheet is already visible, then the
> > .visible line won't cause trouble.
> > (If the workbook's structure is protected, you will get an error, though.)
> >

-- 

Dave Peterson
0
Dave
11/28/2009 8:27:32 PM
Reply:

Similar Artilces:

Problem with "Application.Goto Reference" code line
In my Workbook_Open() subroutine, I run the following line of code: Application.Goto Reference:=Sheets("Sheet1").Range("A1"), scroll:=True This code works okay, but whenever I mark my "Sheet1" as hidden, the code no longer works. The error message that I get is Run-Time Error 1004 - Method 'Goto' of Object '_Application' Failed. Is there any way to use that line of code on a hidden sheet?? thanx The sheet needs to be visible for that code to work. "Robert Crandal" <nobody@gmail.com> wrote in message news:...