ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating Excel Charts using VBA (https://www.excelbanter.com/excel-programming/317072-creating-excel-charts-using-vba.html)

sameerce[_24_]

Creating Excel Charts using VBA
 

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

--
sameerc
-----------------------------------------------------------------------
sameerce's Profile: http://www.excelforum.com/member.php...nfo&userid=807
View this thread: http://www.excelforum.com/showthread.php?threadid=31425


R.VENKATARAMAN

Creating Excel Charts using VBA
 
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 Whe=xlLocationAsObject, Name:="Sheet1"
ActiveChart.Location Whe=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.
sameerce wrote in message
...

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

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

Thanks,
Sameer


--
sameerce
------------------------------------------------------------------------
sameerce's Profile:

http://www.excelforum.com/member.php...fo&userid=8071
View this thread: http://www.excelforum.com/showthread...hreadid=314254





All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com