PDA

View Full Version : Graph in VBA



karrotman
07-26-2012, 11:18 AM
Hi guys,

I'm relatively new to VBA and this is way beyond me. So my macro has outputted the interpolated values. The values in green are the values that match the inputs.

Q1) I made this graph in excel, not VBA. Is there a way to create this graph in VBA? I've made OK graphs, but nothing to this extent. The red line is from the output array and the blue dots are from the input array.

Q2) If I can make that graph, I would like to know how to make it dynamic. Meaning I know I would want to graph to populate Cells(F2:G#) - I will know this number by the time I want to plot the graph but how do I tell VBA that? I've tried this: Cell(F2:G&"OutputLength") but I got an error...

Thanks!

p45cal
08-10-2012, 01:00 AM
You could create a graph from scratch everytime your data changed, but you might prefer the easier route of merely adjusting the plotted ranges; record yourself adjusting the source ranges of the series (click the series on the chart and adjust the extent of the highlighted ranges on the sheet with the mouse).
Then post that code here and we should be able to tweak.
If you were to include your macro which calculates the interpolated points, we could glean the extent of the information from that and incorporate the chart changes into it.

(There is another way to do it without vba by using dynamic named ranges, however, since you're using vba already, there's little point.)