I am using VBA to generate a chart.
With the following code I can select the data from column number 11
to the last column, which I have stored in LastColumnNumber
variable:
ActiveChart.SetSourceData Source:=Union(Sheets(SheetName).Range(Cells(1, 11), Cells(1, LastColumnNumber)), Sheets(SheetName).Range(Cells(4, 11), Cells(4, LastColumnNumber)))
Because I have a lot of zero values before and after the data that I actually need displayed in the chart I am using the following methods to find out the addresses for the first and the last non-zero cells: https://stackoverflow.com/a/42413582/2012740
How can I update the fist piece of code to implement the solutions from the linked answer, and narrow the range for the chart accordingly?