Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello..
There are 2 series in the bar chart one is for Sales and other for Goal and X axis has the Year. The following code refreshes only one series and deletes the other series and X axis values. Any change that I need to do in the code which refreshes both the the series and X-axis. ******************************* Sub SetChartDataSource() Dim NewSet As String Dim NewSet1 As String Dim CurLocation As String CurLocation = ActiveCell.Address NewSet = "B2:" & Range("B2").End(xlDown).Address NewSet1 = "C2:" & Range("C2").End(xlDown).Address ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.PlotArea.Select ActiveChart.SetSourceData Source:=Sheets(ActiveSheet.Name).Range(NewSet) ActiveChart.SetSourceData Source:=Sheets(ActiveSheet.Name).Range(NewSet1) Range(CurLocation).Select End Sub ********************************** |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
The final setsourcedata was simply replacing the first. Try this instead. Sub SetChartDataSource() Dim NewSet As String Dim NewSet1 As String Dim CurLocation As String CurLocation = ActiveCell.Address NewSet = "B2:" & Range("B2").End(xlDown).Address NewSet1 = "C2:" & Range("C2").End(xlDown).Address ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.PlotArea.Select ActiveChart.SetSourceData _ Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t), _ Sheets(ActiveSheet.Name).Range(NewSet1)) ' ActiveChart.SetSourceData 'Source:=Sheets(ActiveSheet.Name).Range(NewSet1) Range(CurLocation).Select End Sub Cheers Andy Joe wrote: Hello.. There are 2 series in the bar chart one is for Sales and other for Goal and X axis has the Year. The following code refreshes only one series and deletes the other series and X axis values. Any change that I need to do in the code which refreshes both the the series and X-axis. ******************************* Sub SetChartDataSource() Dim NewSet As String Dim NewSet1 As String Dim CurLocation As String CurLocation = ActiveCell.Address NewSet = "B2:" & Range("B2").End(xlDown).Address NewSet1 = "C2:" & Range("C2").End(xlDown).Address ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.PlotArea.Select ActiveChart.SetSourceData Source:=Sheets(ActiveSheet.Name).Range(NewSet) ActiveChart.SetSourceData Source:=Sheets(ActiveSheet.Name).Range(NewSet1) Range(CurLocation).Select End Sub ********************************** -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stop excel from dropping the 0 in the beginning of a number? | Setting up and Configuration of Excel | |||
Excel docs not saving as excel docs | Excel Discussion (Misc queries) | |||
Open Excel 2003 from Windows Explorer | Excel Discussion (Misc queries) | |||
Need suggestions for some uses of Ms Excel | Excel Discussion (Misc queries) | |||
Excel Range Value issue (Excel 97 Vs Excel 2003) | Excel Discussion (Misc queries) |