Creating Excel Charts using VBA

S

sameerce

Hi All,
I wanted to use VB code to create a excel file and then based on som
data present in the excel sheet, I want to create a chart on the shee
which will have the data as source.

I am able to create the excel file dynamically and load a few cell
with the data. But, I am stuck up with the graphical part of it. Ca
anyone let me know how to create charts dynamically and give some cell
as the data source for the chart?

Thanks,
Samee
 
R

R.VENKATARAMAN

I have in my harddisk a file basesd on similar critera of yours this
customised for me. you can chang to suit your needs This is based on
knoweldge culled from Jon Peltier and Tushar metha web pages.

I have some columnar data from A1. I insert a name <rv> with refernce to as

=OFFSET(Sheet1!$A$1,0,0,COUNT(Sheet1!$A:$A),1)

the name refeence is given such that the columnar data is dyanamic.
for experiment you ener some data A1 to A10 and name it like above when you
add data in the same column the name takes that into account.

then II ahve a vba code.open sheet2 and runthe code

Public Sub test()
Application.Goto Reference:="rv"
Charts.Add
ActiveChart.ChartType = xlBarStacked

'ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveChart.Location Where:=xlLocationAsObject, Name:="sheet2"
End Sub
see whther you can modify this to suit your needs
the chart is embedded in sheet2

may NOT be very elegant solution.
 

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