Histogram in Excel

J

jtomdd

I have written a macro that uses the data-analysis tool to creat a
histogram. It turns out too small and I have to manually enlarge it. I
can't seem to do it in the macro, because one has to select thee chart
and I can't figure out how to do this since it reuires a chart number
to select it. And of course the number changes every time the macro is
run.

So my question is: In a VBA macro how do I select the only chart when
I will not know it's number. Help will be appreciated. Thank you.
 
A

Andy Pope

Hi,

Some like this will select the most recent chart object on the activesheet.


Dim objCht as ChartObject

set objCht = activesheet.chartobjects(activesheet.chartobjects.count)
objcht.width = 350
objcht.height = 250


Cheers
Andy
 
M

Mike Middleton

jtomdd -

If you do the resizing immediately after the chart is created, maybe you
could use ActiveChart to refer to it.

Instead of using the Histogram tool of the Analysis ToolPak, you may want to
investigate the VBA code of my free Better Histogram add-in, available from
http://www.treeplan.com.

- Mike
http://www.mikemiddleton.com
 

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