Value) The last example shows how to hide all rows that have the same value in column A as in cell A1.For that matter the whole thing could be written in the worksheet's Worksheet_Change procedure, but for the sake of the example I have made the Worksheet_Change procedure call an "ordinary" macro to do some of the work.
You can let Excel scale the axes automatically; when the charted values change, Excel updates the scales the way it thinks they fit best. Or you could assign the code to a button in the worksheet. A more elegant approach is to change the relevant axis when one of the cells within B14: C16 changes.
Or you can manually adjust the axis scales; when the charted values change, you must manually readjust the scales. We can use the has appeared automatically atop the module.
The Work Sheet_Change procedure is activated every time something is changed in the worksheet. The next two macros are examples of what I call "automatic code," because they execute automatically, if a certain condition is met.
The other approach is to run an "ordinary" macro that checks if certain conditions are met. The first example shows how to hide empty columns, and the next example shows how to use the search function and hide rows, if a certain value exists in a given range. So you don't need to do anything active like clicking a button or the like to run the code.
Wouldn’t it be great to be able to link the axis scale parameters to values or, even better, formulas in the worksheet? If you want a ready-to-use solution, try Tushar Mehta’s Auto Chart Manager add-in, available as a free download at You can write the entire procedure yourself, but it’s easier and more reliable to let the VB Editor start it for you.