Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default positioning charts

I am trying to create a number of charts using VBA, but positioning the
charts is giving me trouble. Thanks in advance for any help.

My code:

Set myChart = Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Graph").Range(GraphRange),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Graph"
With myChart.Parent
.Top = Range("C2").Top
.Left = Range("C2").Left
End With

Error:
Run-time error '424'

Object required
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default positioning charts


With ActiveChart.Parent
.Top = Range("C2").Top
.Left = Range("C2").Left
End With


mychart doesn't represent chart after changing location and only
Microsoft knows why.



mike wrote:
I am trying to create a number of charts using VBA, but positioning the
charts is giving me trouble. Thanks in advance for any help.

My code:

Set myChart = Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Graph").Range(GraphRange),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Graph"
With myChart.Parent
.Top = Range("C2").Top
.Left = Range("C2").Left
End With

Error:
Run-time error '424'

Object required

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default positioning charts



--
---
Regards,
Norman



"mike" wrote in message
...
I am trying to create a number of charts using VBA, but positioning the
charts is giving me trouble. Thanks in advance for any help.

My code:

Set myChart = Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData
Source:=Sheets("Graph").Range(GraphRange),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Graph"
With myChart.Parent
.Top = Range("C2").Top
.Left = Range("C2").Left
End With

Error:
Run-time error '424'

Object required



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default positioning charts

Hi Mike,

Try something like:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Dim myChart As ChartObject

Set SH = Sheets("Graph")
Set rng = SH.Range("GraphRange")

Set myChart = SH.ChartObjects.Add(Left:=SH.Range("C2").Left, _
Top:=SH.Range("C2").Top, _
Width:=300, _
Height:=200) '<<=== CHANGE


With myChart.Chart
.ChartType = xlXYScatterLines
.SetSourceData Source:=rng, PlotBy _
:=xlColumns
End With
End Sub
'<<=============


---
Regards,
Norman


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
Positioning charts & pictures with data for printing Papermaker Excel Discussion (Misc queries) 0 November 4th 08 04:36 PM
Positioning all pictures gejmond Excel Discussion (Misc queries) 3 June 26th 06 08:48 PM
Commandbar Positioning PosseJohn Excel Programming 4 December 13th 05 10:30 PM
Positioning Roger[_20_] Excel Programming 4 July 8th 05 08:54 PM
= positioning snax500[_2_] Excel Programming 1 June 28th 04 08:24 PM


All times are GMT +1. The time now is 05:49 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"