Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 93
Default Cannot change title of second chart

Tushar Mehta wrote:

There is almost never a need to select or activate objects. Also, it is very
risky to rely on something being the active object. The code below does what
you want and can be run irrespective of what workbook/sheet is the active
element...as long as the target workbook is open and the appropriate
worksheets exist in it.

Option Explicit

Sub noSelectsOrActivates()
Const TitleName As String = "Stripper Well Survey - "
Dim aWB As Workbook
Set aWB = Workbooks("StripperWellsMod.xls")
'Set aWB = Workbooks("Book3")
Dim SheetColumn As Integer, ChartNum As Integer
SheetColumn = 1
ChartNum = 1
Dim CTitle As String
CTitle = TitleName & aWB.Sheets("#of wells").Cells(43 + ChartNum,
2).Value
With aWB.Worksheets("Charts").ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = CTitle
.ChartArea.Copy
End With

'The variable SheetColumn is apparently incorrectly named _
since it is used to reference a row!

ChartNum = 2
With aWB.Worksheets("Charts")
.Paste
With .ChartObjects(.ChartObjects.Count)
.Top = aWB.Worksheets("Charts").Cells(SheetColumn + 21, 1).Top
.Left = aWB.Worksheets("Charts").Cells(SheetColumn + 21, 1).Left
With .Chart
.HasTitle = True
.ChartTitle.Text = TitleName _
& aWB.Sheets("#of wells").Cells(43 + ChartNum, 2).Value
End With
End With
End With
End Sub

Thanks, will give that a try.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change the size of a chart title box? Gr8fulDavid Charts and Charting in Excel 3 April 2nd 23 06:46 PM
Dynamically change data in chart title Bill James Charts and Charting in Excel 2 January 9th 08 05:17 AM
how can i use a function to change chart title in Excel 2007 Brian Excel Worksheet Functions 2 November 16th 07 06:42 AM
Possible to change chart title and label box widths? [email protected] Charts and Charting in Excel 6 December 18th 06 09:44 PM
change chart title with auto filter Aja Charts and Charting in Excel 1 July 16th 05 06:34 AM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"