R
Robert Baer
Sub Macro5()
'
' Macro5 Macro
' Macro does not change title of second chart
TitleName = "Stripper Well Survey - "
Windows("StripperWellsMod.xls").Activate
Sheets("Charts").Select
Range("A1").Select
SheetColumn = 1
ChartNum = 1
ActiveSheet.ChartObjects("Chart 1").Activate
Sheets("#of wells").Select
RowLoc = LTrim(Str$(43 + ChartNum)) 'eg: B44
NameLoc = "B" + RowLoc
Range(NameLoc).Select 'state name, eg: ALABAMA
CTitle = TitleName + ActiveCell.Value
Sheets("Charts").Select
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A1
Range(TextSheetColumn).Select
ActiveSheet.ChartObjects("Chart 1").Activate
With Worksheets("Charts").ChartObjects("Chart 1").Chart
.HasTitle = True
.ChartTitle.Text = CTitle
End With
' Title is selected at this point and is changed
ActiveChart.ChartArea.Copy
SheetColumn = SheetColumn + 21
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A22
Range(TextSheetColumn).Select
ActiveSheet.Paste
' Now have two identical charts with second one selected
ActiveWindow.Visible = False
Selection.Name = "Chart 2"
' Now have copy with known chart name.. so try implicit loop
ChartNum = 2
Sheets("#of wells").Select
RowLoc = LTrim(Str$(43 + ChartNum)) 'eg: B45
NameLoc = "B" + RowLoc
Range(NameLoc).Select 'state name, eg: ARIZONA
CTitle = TitleName + ActiveCell.Value
Sheets("Charts").Select
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A22
Range(TextSheetColumn).Select
ChartName = "Chart" + Str$(ChartNum)
ActiveSheet.ChartObjects(ChartName).Activate
With Worksheets("Charts").ChartObjects(ChartName).Chart
.HasTitle = True
.ChartTitle.Text = CTitle
End With
' ChartName and CTitle are correct
' Title is NOT selected at this point and is NOT changed
End Sub
'
' Macro5 Macro
' Macro does not change title of second chart
TitleName = "Stripper Well Survey - "
Windows("StripperWellsMod.xls").Activate
Sheets("Charts").Select
Range("A1").Select
SheetColumn = 1
ChartNum = 1
ActiveSheet.ChartObjects("Chart 1").Activate
Sheets("#of wells").Select
RowLoc = LTrim(Str$(43 + ChartNum)) 'eg: B44
NameLoc = "B" + RowLoc
Range(NameLoc).Select 'state name, eg: ALABAMA
CTitle = TitleName + ActiveCell.Value
Sheets("Charts").Select
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A1
Range(TextSheetColumn).Select
ActiveSheet.ChartObjects("Chart 1").Activate
With Worksheets("Charts").ChartObjects("Chart 1").Chart
.HasTitle = True
.ChartTitle.Text = CTitle
End With
' Title is selected at this point and is changed
ActiveChart.ChartArea.Copy
SheetColumn = SheetColumn + 21
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A22
Range(TextSheetColumn).Select
ActiveSheet.Paste
' Now have two identical charts with second one selected
ActiveWindow.Visible = False
Selection.Name = "Chart 2"
' Now have copy with known chart name.. so try implicit loop
ChartNum = 2
Sheets("#of wells").Select
RowLoc = LTrim(Str$(43 + ChartNum)) 'eg: B45
NameLoc = "B" + RowLoc
Range(NameLoc).Select 'state name, eg: ARIZONA
CTitle = TitleName + ActiveCell.Value
Sheets("Charts").Select
TextSheetColumn = "A" + LTrim(Str$(SheetColumn)) 'eg: A22
Range(TextSheetColumn).Select
ChartName = "Chart" + Str$(ChartNum)
ActiveSheet.ChartObjects(ChartName).Activate
With Worksheets("Charts").ChartObjects(ChartName).Chart
.HasTitle = True
.ChartTitle.Text = CTitle
End With
' ChartName and CTitle are correct
' Title is NOT selected at this point and is NOT changed
End Sub