ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pass a variable into a range? (https://www.excelbanter.com/excel-programming/339363-pass-variable-into-range.html)

Ian Fleming[_2_]

Pass a variable into a range?
 
I'm trying to produce a graph in Excel using macros, my problem is that
the amount of data is not always the same (there could be 4 rows or 24
lines), is there any way to pass a variable into a range say for
("A1:M6") = ("A1:M"variable")? I have tried using named ranges but that
just gives me the same issue. Thanks for any help.

Ian B. Fleming
MS Excel and VBA

*** Sent via Developersdex http://www.developersdex.com ***

William[_2_]

Pass a variable into a range?
 
Hi Ian

If your range should include those cells in Column A from A1 to the last
cell in the column and then extend across to Column M, try,,,

Sub test()
Dim r As Range
With ActiveSheet
Set r = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp).Offset(0,
12))
End With
End Sub



--


XL2003
Regards

William



"Ian Fleming" wrote in message
...
I'm trying to produce a graph in Excel using macros, my problem is that
the amount of data is not always the same (there could be 4 rows or 24
lines), is there any way to pass a variable into a range say for
("A1:M6") = ("A1:M"variable")? I have tried using named ranges but that
just gives me the same issue. Thanks for any help.

Ian B. Fleming
MS Excel and VBA

*** Sent via Developersdex
http://www.developersdex.com ***




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

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