Problem with script error in chart

Meenie

New Member
Joined
Jan 3, 2011
Messages
44
I have excel 2003.
I have a BIG spreadsheet with a worksheet for each month. Each worksheet has a lot of formulas.
I have a little macro that makes the sheet open to a specified line because it's so big it always opened to a weird line and you had to remember to scroll to the right line before entering info.
The problem I'm encountering I "think" is related to the macro. When I create a chart and put it in it's own sheet instead of on the sheet where it was created, I get an error message that says:
"runtime error '1004': Method 'range' of object '_Global' failed.
then I have a choice of "end" or "debug"
I can click "end" and the error message goes away, but I'd rather not have that popping up. But I have no idea how to debug it. If I click debug it takes me into vb with all kinds of stuff in there and I have no idea what to do. :(
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Someone wrote the VB code that is not executing correctly -- talking to that person would be the best way to find out what is happening. If that can't be done, then paste a dozen lines above and below the line that is highlighted. (Be sure to indicate which line is causing the error.) And we can give it a shot.

It sounds as if there is a problem in the NewSheet workbook event - probably the code there was written assuming that the new sheet would be a worksheet and not a chart.
 
Upvote 0
Here's what I see when I hit "debug"
<code>Private Sub Workbook_Open()
Application.Goto Sheets("Jan").Range("C4"), True
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.Goto Range("C4"), False
End Sub</code>

If I go into VB here's what I see:
<code>Private Sub Workbook_Open()
Application.Goto Sheets("Jan").Range("C4"), True
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.Goto Range("C4"), False
End Sub</code>

does that help?
 
Upvote 0
Nevermind :) I fixed it.
first I tried to change the "true" to "False" and that didn't work.
so then I tried just deleting that line, and it worked.
I just didn't know what to do with that debugger.
No matter what I did, when I'd click it off it would say something like This Action will cause the debugger to stop, is this ok?
LOL
 
Upvote 0
I think the problem is that the code can't differentiate between worksheets and a dedicated chart sheet and since charts don't have cells, it can't very well go to cell C4.

The true/false bit just decides whether to scroll or not, again not possible on a chart sheet.

try

Code:
if sh.type <> 2 then Application.Goto Range("C4"), False
since if the sheet's type is 2 it will be a chart.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top