Creating and setting location for Excel Charts

  • Thread starter Thread starter Zzzbla
  • Start date Start date
Z

Zzzbla

Hi!

I have to write some code that's supposed to create a report in Excel,
where some of the reports will contain more charts and some less (because
they have less data) and I have to create the charts programmatically
ofcourse.

My problem is that I couldn't figure out how to set the location of the
chart so it will be for example under a sepcific row in the sheet.

Please post an answer!

Thanks in advance!
 
Hi Zzzbla,

Use something like this,

ActiveSheet.ChartObjects(1).Left = Range("E5").Left
ActiveSheet.ChartObjects(1).Top = Range("E5").Top

Hi!

I have to write some code that's supposed to create a report in Excel,
where some of the reports will contain more charts and some less (because
they have less data) and I have to create the charts programmatically
ofcourse.

My problem is that I couldn't figure out how to set the location of the
chart so it will be for example under a sepcific row in the sheet.

Please post an answer!

Thanks in advance!

--

Cheers
Andy

http://www.andypope.info
 
Thanks a bunch!

I didn't figure there's a difference between Chart and ChartObject...

Almost copied charts to Word as a last resort... :)

Thanks again,
Zzzbla
 
To augment Andy's much more prompt response.

You can set the position and size of a chart when creating it in VBA.

Dim myChtObj As Chart Object
With ActiveSheet
Set myChtObj = .ChartObjects.Add(.Range("E5").Left, _
.Range("E5").Top, .Range("E5:L22").Width, _
.Range("E5:L22").Height)
End With

- Jon
 
Back
Top