Code || VBA, .NET, SQL

Align Secondary Axis in VBA, C#, and VB.NET

Recently, I was asked to align two axes in a particular chart as part of a process that generated 100+ files, each with a chart of this type, ran regularly. The code was prototyped in VBA, but I am also working with a team that will need to replicate the process in server-side .NET, so converted the code to a C# class, and then ran it through Telerik's code convertor to get VB.

The general algorithm used for aligning a chart's secondary axis with the primary axis:

Get primary and secondary divisors

Get upper and lower bounds of secondary axis

Get larger of the larger absolute value of the secondary axis

Multiply (max/min) divisor by each of an array of numbers to find the first multiplier larger than absolute maximum