ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using variables to set ranges (https://www.excelbanter.com/excel-programming/284089-using-variables-set-ranges.html)

Dave Marden[_2_]

using variables to set ranges
 
is it possible to use a variable to set a range such as I
am trying to do here?

ChartNames = Range("'DataCollection'!A1503:BR1503")
SeriesRanges = Range("'DataCollection'!A1505:BR1505")
Sheets("DataCollection").Select
Charts.Add
With ActiveChart
.ChartType = xlLineMarkers
.SetSourceData Range(SeriesRanges(1, 1)),
PlotBy:=xlColumns
.SeriesCollection(1).XValues = Range
("SeriesCollection")
.SeriesCollection(1).Name = "=DataCollection!R1C5"
.Location Whe=xlLocationAsNewSheet,
Name:=ChartNames(1)

ChartNames is just Names, but SeriesRanges are Ranges. I
want to be able to assign ranges in this manner because
then i can use a for/next loop to assign multiple ranges
which change frequently.

Thanks,
Dave Marden



mudraker[_47_]

using variables to set ranges
 

yes it is possible



SeriesRanges = Range("'DataCollection'!A1505:BR1505")

try


strCol = "BR"
intRow = 1505


SeriesRanges = Range("'DataCollection'!A1505:" & strCol & intRow

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements


All times are GMT +1. The time now is 09:17 AM.

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