Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Range related for chart

Hi,

Columns B and C are dynamic (# values/#entries will vary) and the code
should set the source data accordingly for the graph.

In the code below, it changes the value of Column B ONLY, But Column C is
not considered it stops way above the enod of value (example if the last cell
with value is C45, it might stop at C40 etc). Appreciate any help??

*******************************
Sub SetDataSource()

Dim NewSet1 As String
Dim NewSet2 As String
Dim CurLocation As String
CurLocation = ActiveCell.Address
NewSet1 = "B2:" & Range("B2").End(xlDown).Address
NewSet2 = "C2:" & Range("C2").End(xlDown).Address

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData _
Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t1), _
Sheets(ActiveSheet.Name).Range(NewSet2))

Range(CurLocation).Select

End Sub

**************************

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 695
Default Range related for chart

Try (take from row 2 to last row with values
if there is som values down the sheet u dont want
in ur chart, then change 65500 to the last row u want in


Sub SetDataSource()

Dim NewSet1 As String
Dim NewSet2 As String
Dim CurLocation As String
CurLocation = ActiveCell.Address
NewSet1 = "B2:" & Range("B65500").End(xlUp).Address
NewSet2 = "C2:" & Range("C65500").End(xlUp).Address

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData _
Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t1), _
Sheets(ActiveSheet.Name).Range(NewSet2))

Range(CurLocation).Select

End Sub




"Joe" skrev:

Hi,

Columns B and C are dynamic (# values/#entries will vary) and the code
should set the source data accordingly for the graph.

In the code below, it changes the value of Column B ONLY, But Column C is
not considered it stops way above the enod of value (example if the last cell
with value is C45, it might stop at C40 etc). Appreciate any help??

*******************************
Sub SetDataSource()

Dim NewSet1 As String
Dim NewSet2 As String
Dim CurLocation As String
CurLocation = ActiveCell.Address
NewSet1 = "B2:" & Range("B2").End(xlDown).Address
NewSet2 = "C2:" & Range("C2").End(xlDown).Address

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData _
Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t1), _
Sheets(ActiveSheet.Name).Range(NewSet2))

Range(CurLocation).Select

End Sub

**************************

  #3   Report Post  
Posted to microsoft.public.excel.misc
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Range related for chart

Hi,

Thanks for the input/suggestion. I have a graph based on this and this will
skew up my graph..

Thanks & Regards

"excelent" wrote:

Try (take from row 2 to last row with values
if there is som values down the sheet u dont want
in ur chart, then change 65500 to the last row u want in


Sub SetDataSource()

Dim NewSet1 As String
Dim NewSet2 As String
Dim CurLocation As String
CurLocation = ActiveCell.Address
NewSet1 = "B2:" & Range("B65500").End(xlUp).Address
NewSet2 = "C2:" & Range("C65500").End(xlUp).Address

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData _
Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t1), _
Sheets(ActiveSheet.Name).Range(NewSet2))

Range(CurLocation).Select

End Sub




"Joe" skrev:

Hi,

Columns B and C are dynamic (# values/#entries will vary) and the code
should set the source data accordingly for the graph.

In the code below, it changes the value of Column B ONLY, But Column C is
not considered it stops way above the enod of value (example if the last cell
with value is C45, it might stop at C40 etc). Appreciate any help??

*******************************
Sub SetDataSource()

Dim NewSet1 As String
Dim NewSet2 As String
Dim CurLocation As String
CurLocation = ActiveCell.Address
NewSet1 = "B2:" & Range("B2").End(xlDown).Address
NewSet2 = "C2:" & Range("C2").End(xlDown).Address

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData _
Source:=Union(Sheets(ActiveSheet.Name).Range(NewSe t1), _
Sheets(ActiveSheet.Name).Range(NewSet2))

Range(CurLocation).Select

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
Non updatable Unique Random Number Ian Excel Worksheet Functions 30 September 28th 06 08:19 PM
self-sizing adv.filter criteria range BorisS Excel Discussion (Misc queries) 3 September 24th 06 01:30 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Wrap Text Across Columns & Rows Michael Excel Dude Excel Discussion (Misc queries) 1 September 4th 06 02:14 AM
Duplicate Range Names by worksheet FlaAl Excel Discussion (Misc queries) 0 May 24th 06 05:14 PM


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