If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Code Modification
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 |
#2
|
|||
|
|||
Code Modification
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 Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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 |
#3
|
|||
|
|||
Compile Error
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? -----Original Message----- 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 Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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 . |
#4
|
|||
|
|||
Compile Error
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 ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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? -----Original Message----- 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 Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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 . |
#5
|
|||
|
|||
Compile Error
I used it and it does work. Thanks for your help.
-----Original Message----- 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 ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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? -----Original Message----- 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 Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Phil Hageman wrote: 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 . . |
Thread Tools | |
Display Modes | |
|
|