Hi everybody,
I have a series of coordinates in a range. I would like to plot them as points using VBA.
Is there a web link which gives tips in how to plot and edit a chart using VBA???
thanks
Hi everybody,
I have a series of coordinates in a range. I would like to plot them as points using VBA.
Is there a web link which gives tips in how to plot and edit a chart using VBA???
thanks
Last edited by adilson.perez; 01-08-2011 at 08:29 PM.
I don't know of any one specific web site, but you can look in the VBA object browser for the Chart and Series objects to get started.
You might also try to Google "Excel VBA chart".
What do you need to do that requires VBA? You certainly don't need VBA to plot a series of coordinates in a range.
Jeff
| | |·| |·| |·| |·| | |:| | |·| |·|
Read the rules
Use code tags to [code]enclose your code![/code]
I have written a macro that calculates certain values for a group of bolts in a structural connection. The program asks through an userform the coordinates of each bolt and writes the values in a range that is specified. I would like to plot those coordinates as points simulating the bolt group connection. Since the connection may have as many bolts as the users decide, the macro should read the values until there is nothing in the cells. But I don't know how to write the code to plot.
For example I have the first coordinate for X in Range("B7") and for Y in Range("D7") the next coordinate for X in Range("B8") and for Y in Range("D8") and so for.
Thanks for your help
I would suggest creating a chart using the desired ranges allowing axis options to be automatic. Then the chart will be automatically adjusted to reflect the data your VBA generates, without having to manipulate the chart with VBA.
I can illustrate better if you could post an example of the workbook you're building.
I have attached the file for you to see it better. Since I don't know how many bolts will be in the connection I think I must program the chart so it plots as points all coordinates, whether there are 2 bolts, 10 and so for.
thanks for your replies
I suggest you change your data format to have two columns dedicated to the bolt coordinates, and two more dedicated to the squares of the bolt coordinates, instead of including them in columns that also contain other data. That greatly simplifies the plotting problem. The chart series can refer to the entire column and manage everything else automatically.
I will see if I can provide a revision, including an update to your VBA. However, your code has range references hard coded so it would need a lot of revisions. I have two strategies for managing this. One is to create named ranges in the spreadsheet and use those as anchor points for tables of data. For example, you could have X1 name the cell where the first X value will be placed. Then make all references to cells in the table relative to that anchor point.
Another strategy is to create a variable in the code to achieve the same thing![]()
Please Login or Register to view this content.
This allows you to change the table location and change at most one line of code. In the existing code there are maybe dozens of places that need to be changed.![]()
Please Login or Register to view this content.
I would also suggest turning off screen updating during calculation, which should speed things up a bit.
I tried running it, but I do not understand the engineering involved, so my input was probably nonsense. But I noted that your code is subject to divide by zero errors. You will want to identify where that could happen and whether there is legitimate input that can cause that result, or prevent bad input from causing it.
Here is an example of a suggested data layout. I discovered you can't plot more than 32K points so I can't select the entire column for a plot. For purposes of this example I specified a range of 100 rows, although there are only 18 data points. The updated layout is in "ICR - Results (2)" and the chart is in "Plot".
The update to the VBA is incomplete so this is just for looking at, not executing.
Thanks 6StringJazzer
You are right, it is better the layout y provided me with and easier to code it. I've heard about turning off screen during calculations but I don't know how its supposed to be written. Can you help me on that??
I found it
thanks for all the help
I think I can put Solved in this one
once again thanks
Glad to see I was able to help. I didn't think we were quite there yet--let me know if I can do something else.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks