Is there a method for refreshing an object variable?

  • Thread starter Thread starter uno@korsmaa
  • Start date Start date
U

uno@korsmaa

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
 
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...
 
Back
Top