Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I change the size of a chart title box? | Charts and Charting in Excel | |||
Dynamically change data in chart title | Charts and Charting in Excel | |||
how can i use a function to change chart title in Excel 2007 | Excel Worksheet Functions | |||
Possible to change chart title and label box widths? | Charts and Charting in Excel | |||
change chart title with auto filter | Charts and Charting in Excel |