ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   manually specifing a range in the code below (https://www.excelbanter.com/excel-programming/299494-manually-specifing-range-code-below.html)

Neo[_2_]

manually specifing a range in the code below
 
see the code
i want to create a XY scatter chart, using data from
y-axis = data from column 1 - row 3 to row 11 an
x-axis = data from column 4 - row 3 to row 11

Charts.Ad
ActiveChart.ChartType = xlXYScatterSmoothNoMarker
ActiveChart.SeriesCollection(1).Delet
ActiveChart.SeriesCollection.NewSerie
ActiveChart.SeriesCollection.NewSerie
ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!R3C4:R11C4
ActiveChart.SeriesCollection(1).Values = "='Sheet1'!R3C1:R11C1

but the no of rows can be variable, so how can i pass no of rows (like "from row 3 to row 12" or "from row 3 to row 15") to the proceedure. i just want to pass 11 or 12 or 15 or whatever, instead of saying "Sheet1'!R3C4:R11C4

Is there any way..pls hel


David

manually specifing a range in the code below
 
You have to find the row number and put it in a variable
ie. get to the place (address) and find the row number -
ThisRow = Activecell.Row, then use that variable in your
Code ie.

ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!R" &
(ThisRow) & "C4:R11C4"

(Above - ThisRow replaces the 3)

Thanks
-----Original Message-----
see the code,
i want to create a XY scatter chart, using data from
y-axis = data from column 1 - row 3 to row 11 and
x-axis = data from column 4 - row 3 to row 11.

Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection(1).Delete
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!

R3C4:R11C4"
ActiveChart.SeriesCollection(1).Values = "='Sheet1'!

R3C1:R11C1"

but the no of rows can be variable, so how can i pass no

of rows (like "from row 3 to row 12" or "from row 3 to
row 15") to the proceedure. i just want to pass 11 or 12
or 15 or whatever, instead of saying "Sheet1'!R3C4:R11C4"

Is there any way..pls help

.



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

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