Code Modification

  • Thread starter Thread starter Phil Hageman
  • Start date Start date
P

Phil Hageman

The below code is assigned to a command button, which
moves the user to the worksheet "Metrics", cell A1. On
that worksheet is "Chart13" (among others). I need to
modify this code to: 1.) Select the chart, 2.) Size
height and width, and 3.) Give it a centered location on
screen.

Can someone help modify this code?

Sub GoToMetricsA1()
' GoToMetricsA1 Macro
Sheets("Metrics").Select
Range("A1").Select
End Sub

Thanks,
Phil
 
Phil -

If you don't care about moving the chart:

Sub GoToMetricsA1()
' GoToMetricsA1 Macro
Sheets("Metrics").Select
Range("A1").Select
ChartObjects("Chart13").activate
With ActiveChart.Parent
.Height = 250 ' use desired height in points
.Width = 350 ' use desired width in points
.Left = (Windows(ActiveWorkbook.Name).Width - _
.Width)/2
.Top = (Windows(ActiveWorkbook.Name).Height - _
.Height)/2
End With
End Sub

- Jon
 
Jon, Thanks much for your reply - I appreciate your time.
I entered the code and received a compile error: Sub or
Function not defined. "ChartObjects" is highlighted. No
spelling errors. Any idea what have I done wrong?
 
Phil -

Try this amendment:

ActiveSheet.ChartObjects("Chart13").activate

It worked without the "ActiveSheet." from the immediate window, so I
didn't include it in the procedure, where it is necessary. Sorry.

- Jon
 
Back
Top