You don't need VBA at all. I know what you want, and I already created it. I will explain how you do it for the maximum position, since you do this for the minimum. First we need to find the maximum mark of the Y axis, and then it becomes easy.
Let me break it down into five steps:
- A in the formulas: Determine the scale.
- B in the formulas: Compare on this scale.
- C in the formulas: Measure the interval.
- D in the formulas: round it.
- E in the formulas: Calculate the maximum mark axis.
OK, here are the formulas for each step:
- = ROUNDDOWN (LOG (MAX (data)); 1) where data indicates cells containing your values.
- = MAX (data) / 10 ^ A) * 1.05
- = 0.2 + (B> 2) * 0.3 + (B> 5) * 0.5
- = ROUNDDOWN (B, C)
- = (C + D) * 10 ^ A
I myself use Dutch formulas, so I could make a small translation mistake. Other than that, I promise it will work. The reason is that I understood how Excel βthinksβ with graphs. I will try to explain how this works.
Basically, there are three main ranges for using Excel: from 1 to 2, from 2 to 5, and from 5 to 10. When the number is greater than 10, 10 will be considered 1 again, and you will return to the first range. This is why we first scale using the LOG formula. If you are new to this, check it out on the wiki.
So, when we have a scale, we determine in which range it falls. For each of these three ranges, the intervals between the Y axis labels are different. Therefore, we calculate them in the third step and use it in the fourth step to round the number B down. The fifth step simply multiplies it by the original scale.
And here you are: the Max Y-axis label is found. Look at the chart and it should be the same. If you get this idea, you will also find the minimum Y-axis label. Now the cool thing is that you can easily figure out where the label should go EXACTLY because now you know the size of the grid.
Good luck with this, and if you still have questions, let me know.
Patrick