ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference problems (https://www.excelbanter.com/excel-programming/364846-reference-problems.html)

franzklammer

Reference problems
 
Hi! I am trying to make a chart. I cannot refer directly to the cells since
the contents and plecment in spreadsheet is variable. I have 2 problems. 1)
When choosing the area from which get data for the chart I select cells in
the wrong worksheet. when trying to add a reference regarding the worksheet i
get error. the code for this part is:

Range(rng1.Address, rng1.Offset(i, j).Address).Select

I want this code to select cells in a certain worksheet.

2) I cannot refer to multiple ranges in making the chart with indirect
reference. My code for this is:

Range(rng1.Address, rng1.Offset(i, j).Address).Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData
Source:=Sheets("Indata").Range("rng1.Address:rng1. Offset(1, 0).Address,
rng2.Address:rng2.Offset(3,0).Address"), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues =
Sheets("Indata").Range(rng.Offset(0, 1).Address, rng.Offset(0, i).Address)

but the program does not accept this way of defining a range. PLease help me
find the correct way!!!!!!!!

Charlie

Reference problems
 
Maybe this:

Source:=Sheets("Indata").Range(rng1.Address & ":" & rng1.Offset(1,
0).Address & ":" & rng2.Address & ":" & rng2.Offset(3, 0).Address)

"franzklammer" wrote:

Hi! I am trying to make a chart. I cannot refer directly to the cells since
the contents and plecment in spreadsheet is variable. I have 2 problems. 1)
When choosing the area from which get data for the chart I select cells in
the wrong worksheet. when trying to add a reference regarding the worksheet i
get error. the code for this part is:

Range(rng1.Address, rng1.Offset(i, j).Address).Select

I want this code to select cells in a certain worksheet.

2) I cannot refer to multiple ranges in making the chart with indirect
reference. My code for this is:

Range(rng1.Address, rng1.Offset(i, j).Address).Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData
Source:=Sheets("Indata").Range("rng1.Address:rng1. Offset(1, 0).Address,
rng2.Address:rng2.Offset(3,0).Address"), PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues =
Sheets("Indata").Range(rng.Offset(0, 1).Address, rng.Offset(0, i).Address)

but the program does not accept this way of defining a range. PLease help me
find the correct way!!!!!!!!



All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com