Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Interactive Chart/ "Method Cells of object '_global' failed"


Hi all,

I have a chart with time period on axis. I want the user of this char
to be able to change this time period via a button.
here is the beginning of the macro link to the button. the macro bug
when I want the series to be defined depending on the calculated ro
numbers of the series (in bold in the macro).
The error message is "Method Cells of object '_global' failed"

Do anyone have a solution for this problem ?
Many thanks

Sibilia

Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by th
user
EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear) 'Calculte the row numbe
where is the StartYear2

EndLine = 103 - (EndYear2 - EndYear) 'Calculte the row number where i
the EndYear2

Sheets("Incidence").Activate
ActiveSheet.ChartObjects("Chart 32").Activate
*ActiveChart.SeriesCollection(1).XValues
ActiveSheet.Range(Cells(StartLine, "W"), Cells(EndLine, "W"))
'ActiveSheet.Range("W3:W103")*
....

--
Sibili
-----------------------------------------------------------------------
Sibilia's Profile: http://www.excelforum.com/member.php...fo&userid=2136
View this thread: http://www.excelforum.com/showthread.php?threadid=38383

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Interactive Chart/ "Method Cells of object '_global' failed"

Hi Sibilia,

It looks like your chart is active when you try to call the ActiveSheet
method. This will cause the error because a chart sheet doesn't have any
cells. Try modifying your code like so:

With Sheets("Incidence")
.ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
.Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))
End With

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Sibilia" wrote in
message ...

Hi all,

I have a chart with time period on axis. I want the user of this chart
to be able to change this time period via a button.
here is the beginning of the macro link to the button. the macro bugs
when I want the series to be defined depending on the calculated row
numbers of the series (in bold in the macro).
The error message is "Method Cells of object '_global' failed"

Do anyone have a solution for this problem ?
Many thanks

Sibilia

Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the
user
EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear) 'Calculte the row number
where is the StartYear2

EndLine = 103 - (EndYear2 - EndYear) 'Calculte the row number where is
the EndYear2

Sheets("Incidence").Activate
ActiveSheet.ChartObjects("Chart 32").Activate
*ActiveChart.SeriesCollection(1).XValues =
ActiveSheet.Range(Cells(StartLine, "W"), Cells(EndLine, "W"))
'ActiveSheet.Range("W3:W103")*
....


--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile:
http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=383839



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Interactive Chart/ "Method Cells of object '_global' failed"


Great! :) It works!!!! but as the graph got x and Y Axis, I tried to
use the same code for the second axis ; So the code becomes:

With Sheets("Incidence")
..ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
..Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))

..ChartObjects("Chart 32").Chart.SeriesCollection(1).Values = _
..Range(.Cells(StartLine, "X"), .Cells(EndLine, "X"))
End With


But when I do this using F8, it is ok , it works. But when I link the
macro to a button then it stops with this message: Type mismatch.
Don't know what to do ... .

Many thanks anyway!


--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile: http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=383839

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Interactive Chart/ "Method Cells of object '_global' failed"

Hi Sibilia,

If you are using an ActiveX CommandButton, make sure you have its
TakeFocusOnClick property set to False.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Sibilia" wrote in
message ...

Great! :) It works!!!! but as the graph got x and Y Axis, I tried to
use the same code for the second axis ; So the code becomes:

With Sheets("Incidence")
ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))

ChartObjects("Chart 32").Chart.SeriesCollection(1).Values = _
Range(.Cells(StartLine, "X"), .Cells(EndLine, "X"))
End With


But when I do this using F8, it is ok , it works. But when I link the
macro to a button then it stops with this message: Type mismatch.
Don't know what to do ... .

Many thanks anyway!


--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile:
http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=383839



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel-VBA: "1004 - Method 'Range' of object '_Global' failed" THA Excel Programming 1 May 18th 05 09:18 AM
Method 'Cells' of object '_Global' failed Huyeote[_10_] Excel Programming 0 October 19th 04 07:29 AM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM
Excel VBA - Storing text in a variable, and "'Cells' of object _Global failed" engineer[_2_] Excel Programming 3 April 23rd 04 11:35 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"