A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Code Modification



 
 
Thread Tools Display Modes
  #1  
Old October 28th, 2003, 04:45 PM
Phil Hageman
external usenet poster
 
Posts: n/a
Default 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  
Old October 28th, 2003, 06:42 PM
Jon Peltier
external usenet poster
 
Posts: n/a
Default 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  
Old October 28th, 2003, 07:17 PM
Phil Hageman
external usenet poster
 
Posts: n/a
Default 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  
Old October 29th, 2003, 09:52 PM
Jon Peltier
external usenet poster
 
Posts: n/a
Default 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  
Old October 30th, 2003, 11:40 AM
Phil Hageman
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.