#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Replace...

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: 50
Default Replace...

How about updating the range property of the chart instead of recreating the
chart?

Sheets("My Sheet Tab Name").ChartObjects("NC TREND PER
SHIFT1").SetSourceData Source:=Sheets("NC TREND").Range("B4:G4,B12:G12")

Good Luck
--
Stewart Rogers
DataSort Software, L.C.


"anamarie30" wrote:

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
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
How to Replace multiple words to replace using excell ramsun Excel Programming 1 August 10th 06 01:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
How can I use replace(alt+H) for mutiple items needing replace Gery Excel Worksheet Functions 1 June 15th 05 05:51 PM


All times are GMT +1. The time now is 07:53 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"