Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

I have been having a problem when trying to create a chart on Excel.

Basically the code is like this:

With ActiveChart
.SetSourceData newBook.Worksheets("Output Data").Range(Cells(1
7), Cells(SampleSize + 1, 8))
.HasTitle = True
.ChartType = xlXYScatter
.ChartTitle.Characters.Text = "Linearized Weibull chart"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "x1"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "y1"
End With

The problem occurs on .SetSourceData line.

newBook is public and set to the workbook currently active an
SampleSize is 196 at the time (And declared locally) and at line 19
there is data so I don't see what is causing it.

Has anybody got this error before? It's been driving me mad.


Best Regards

Noo

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

Hi Nook
Try
SetSourceData newBook.Worksheets("Output Data").Range(Cells(1,7),
Cells(SampleSize + 1, 8)).Address

HTH
Cordially
Pascal

"NooK " a écrit dans le message de
...
I have been having a problem when trying to create a chart on Excel.

Basically the code is like this:

With ActiveChart
SetSourceData newBook.Worksheets("Output Data").Range(Cells(1,
7), Cells(SampleSize + 1, 8))
HasTitle = True
ChartType = xlXYScatter
ChartTitle.Characters.Text = "Linearized Weibull chart"
Axes(xlCategory, xlPrimary).HasTitle = True
Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "x1"
Axes(xlValue, xlPrimary).HasTitle = True
Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "y1"
End With

The problem occurs on .SetSourceData line.

newBook is public and set to the workbook currently active and
SampleSize is 196 at the time (And declared locally) and at line 197
there is data so I don't see what is causing it.

Has anybody got this error before? It's been driving me mad.


Best Regards

NooK


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

I had already tried with Worksheets instead of Sheets but not Addres
and I still get the same error. :(

Hopefully it is not a hopeless case.

Best Regards

Noo

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

Hi NooK,

My guess is that the problem is that you're using unqualified calls to
the Cells method. Here's a revised example that will fix the problem if this
is it:

Dim wksSource As Worksheet
Set wksSource = newBook.Worksheets("Output Data")
With ActiveChart
.SetSourceData wksSource.Range(wksSource.Cells(1, 7), _
wksSource.Cells(SampleSize + 1, 8))
'......
End With

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

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"NooK " wrote in message
...
I have been having a problem when trying to create a chart on Excel.

Basically the code is like this:

With ActiveChart
SetSourceData newBook.Worksheets("Output Data").Range(Cells(1,
7), Cells(SampleSize + 1, 8))
HasTitle = True
ChartType = xlXYScatter
ChartTitle.Characters.Text = "Linearized Weibull chart"
Axes(xlCategory, xlPrimary).HasTitle = True
Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "x1"
Axes(xlValue, xlPrimary).HasTitle = True
Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "y1"
End With

The problem occurs on .SetSourceData line.

newBook is public and set to the workbook currently active and
SampleSize is 196 at the time (And declared locally) and at line 197
there is data so I don't see what is causing it.

Has anybody got this error before? It's been driving me mad.


Best Regards

NooK


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

How about your SampleSize variable?
Does it return the expected number?
Also, what does the variable newbook return?

HTH
Cordially
Pascal

"NooK " a écrit dans le message de
...
I had already tried with Worksheets instead of Sheets but not Address
and I still get the same error. :(

Hopefully it is not a hopeless case.

Best Regards

NooK


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error '1004' (Method 'Cells' of '_Global' Failed) On chart creation?

Sorry for delay Guys, it was holiday here on Friday and at the moment
only have internet at work.

Rob's suggestion worked, I still don't quite understand why but I go
no problems anymore, so Thanks a lot both for the help given.

Best Regards

Noo

--
Message posted from http://www.ExcelForum.com

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
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
Error 1004: Method 'Cells' of object '_Global' failed LT Excel Programming 2 October 31st 03 04:47 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 03:38 AM.

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

About Us

"It's about Microsoft Excel"