Creating and setting location for Excel Charts

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!
 
A

Andy Pope

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
 
Z

Zzzbla

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
 
J

Jon Peltier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top