If, like me, you spend a lot of time building spreadsheets with charts, you will want to make sure they are all lined up and neat.
This is how I do it. You can get this whole process done in seconds with a bit of practice :-).
- Select the range of cells that you want your chart to cover.
- Name it “foo”. You can do that quickly with the keyboard shortcut Alt+i n d (so Alt+i, then ‘n’ and then ‘d’) which brings up the Name Range box.
- Use Alt+F11 to bring up your VBA window and select View->Immediate (or use Ctrl+G).
- Select the chart.
- Paste the following code into the immediate window:
ActiveChart.Parent.Left = Range("foo").Left ActiveChart.Parent.Top = Range("foo").Top ActiveChart.Parent.Height = Range("foo").Height ActiveChart.Parent.Width = Range("foo").Width
- Run each line: put your cursor at the end of the first line and hit Enter to run each line by line.