ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a method for refreshing an object variable? (https://www.excelbanter.com/excel-programming/280176-there-method-refreshing-object-variable.html)

uno@korsmaa

Is there a method for refreshing an object variable?
 
Hello

I want to define a range as an object variable at the beginning of the
procedure as a dynamic range.

Does there exist a method that would enable me to refresh the variable when
I need to, later in the code?

Rergards
Uno Kõrsmaa



steve

Is there a method for refreshing an object variable?
 
The only way I know is to set the range each time:

Dim x as Long
Dim rng as Range

x = ????
Set rng = Range("A1:D" & x)

* more code *
x = ????
Set rng = Range("A1:D" & x)

you might use:
x = Cells(Rows.COUNT, "A").End(xlUp).Row
to set x to the last used row in column A
or:
x = Cells(Rows.COUNT, "A").End(xlUp).Offset(1, 0).Row
to set x to the blank row after the last used row in column A.

There might be a way to build an Offset function and evaluate during the
code execution. but I don't know how to do this...

--
sb
"uno@korsmaa" wrote in message
...
Hello

I want to define a range as an object variable at the beginning of the
procedure as a dynamic range.

Does there exist a method that would enable me to refresh the variable

when
I need to, later in the code?

Rergards
Uno Kõrsmaa






All times are GMT +1. The time now is 01:49 PM.

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