Is there a method for refreshing an object variable?

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
 
S

steve

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top