Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Need to replace existinf graph for new graph with the same name

I need to include in this code the following thing.

1. Suppose that a graph called "TEST" already exixt.
2. I run my macro for created a new graph called "TEST".
3. I want that the macro reconized the graph described in step 1 and
replaced it with the new graph described in step 2.

How can I do that? Here it my code:



Sub TEST()

Dim CHT As Chart

Set CHT = Charts.Add
With CHT
.Name = "NC TREND PER SHIFT1"
.ChartType = xlColumnClustered
.SetSourceData Source:=Sheets("NC TREND").Range("B4:G4,B12:G12"),
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Characters.Text = Sheets("NC Trend").Cells(1, 1)
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SHIFT"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "AVERAGE NC"
.HasLegend = False
.SeriesCollection(1).HasDataLabels = True
End With

With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 10
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Need to replace existinf graph for new graph with the same name

on error resume next
charts("TEST").delete
on error goto 0


Tim


"anamarie30" wrote in message
...
I need to include in this code the following thing.

1. Suppose that a graph called "TEST" already exixt.
2. I run my macro for created a new graph called "TEST".
3. I want that the macro reconized the graph described in step 1 and
replaced it with the new graph described in step 2.

How can I do that? Here it my code:



Sub TEST()

Dim CHT As Chart

Set CHT = Charts.Add
With CHT
.Name = "NC TREND PER SHIFT1"
.ChartType = xlColumnClustered
.SetSourceData Source:=Sheets("NC TREND").Range("B4:G4,B12:G12"),
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Characters.Text = Sheets("NC Trend").Cells(1, 1)
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SHIFT"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "AVERAGE NC"
.HasLegend = False
.SeriesCollection(1).HasDataLabels = True
End With

With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 10
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Need to replace existinf graph for new graph with the same nam

Thanks for your help! It work great!!

"Tim Williams" wrote:

on error resume next
charts("TEST").delete
on error goto 0


Tim


"anamarie30" wrote in message
...
I need to include in this code the following thing.

1. Suppose that a graph called "TEST" already exixt.
2. I run my macro for created a new graph called "TEST".
3. I want that the macro reconized the graph described in step 1 and
replaced it with the new graph described in step 2.

How can I do that? Here it my code:



Sub TEST()

Dim CHT As Chart

Set CHT = Charts.Add
With CHT
.Name = "NC TREND PER SHIFT1"
.ChartType = xlColumnClustered
.SetSourceData Source:=Sheets("NC TREND").Range("B4:G4,B12:G12"),
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Characters.Text = Sheets("NC Trend").Cells(1, 1)
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SHIFT"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "AVERAGE NC"
.HasLegend = False
.SeriesCollection(1).HasDataLabels = True
End With

With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 10
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

End Sub




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
Combining a 2-D column graph and a 2-D line graph on the same char Filippo Charts and Charting in Excel 3 February 23rd 10 12:34 AM
How do I graph data daily as a line graph across a calendar format Glani Charts and Charting in Excel 3 November 23rd 07 09:05 AM
Cluster stacked graph AND line combo graph? [email protected] Charts and Charting in Excel 6 October 14th 06 12:33 AM
Creating a graph similar to a stacked column graph Jonathan Charts and Charting in Excel 6 August 4th 06 04:23 PM
Hyperlinkage of one graph with another graph or Drill down graph Sanjay Kumar Singh Charts and Charting in Excel 1 January 3rd 06 12:22 PM


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

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

About Us

"It's about Microsoft Excel"