Creating Charts using VBA

Joined
Nov 23, 2011
Messages
1
Reaction score
0
Hi! I need a little help with something. Using VBA to macro some excel data.
I want to create a chart using arrays created in Visual Basics, instead of from the cell range i excel.

What i'm refering to is the part in bold and dark red. It's actually a range of cell values in excel i assume, but the thing is that I've got different sets of data, where this specific data type is not always in the same position in the excel sheet. So I cant specify a set of range. So what i did was to convert that specific data type to an array, but I have no idea if I can create a chart, using that set of array.

Btw, i'm pretty new to programming, so my terms may not really be right :X

Example: from http://msdn.microsoft.com/en-us/library/aa203725(v=office.11).aspx
Sub AddChartSheet()
Dim chtChart As Chart
'Create a new chart.
Set chtChart = Charts.Add
With chtChart
.Name = "Tool Sales2"
.ChartType = xlColumnClustered
'Link to the source data range.
.SetSourceData Source:=Sheets("Sheet1").Range("A1:H5"), _
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Text = "=Sheet1!R1C2"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Sales"
End With
End Sub


Ok i change the range from D5 to H5, coz with the colon it gives me :D =.=

Thanks alot!!
 
Last edited:

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

Similar Threads


Top