ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting A Range (https://www.excelbanter.com/excel-programming/369802-setting-range.html)

reggie

Setting A Range
 
Is is possible to to set a range in VB and have any sub use it? If so how
would i be able to do this? Code so far

Set plane = Worksheets("Sheet1").Range("A98")

i want the range "plane" to be used throughout the worksheet.

moon[_5_]

Setting A Range
 

Just pass the range as an argument in your sub...

Public Sub RangeDemo(r As Range)
Dim e As Variant 'every element in range
For Each e In r
MsgBox r.Value
Next
End Sub




"Reggie" schreef in bericht
...
Is is possible to to set a range in VB and have any sub use it? If so how
would i be able to do this? Code so far

Set plane = Worksheets("Sheet1").Range("A98")

i want the range "plane" to be used throughout the worksheet.





All times are GMT +1. The time now is 10:37 AM.

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