The problem is that you're not properly using the Range data type and
the Set keyword. If you use MyRange as a Range object, it's only going
to apply to the specific sheet and range you used when you set it
(ActiveSheet by default). To generalize the range for all sheets,
there are (at least) two ways to do it:
First:
---------------
Dim MyRange as String
MyRange = "B19:I26"
Worksheet(<Whatever>).Range(MyRange).Select
---------------
Second:
---------------
Dim MyRange as Range
Set MyRange = Range("B19:I26")
Worksheet(<Whatever>).Range(MyRange.Address).Select
---------------
The first is probably best because you save a little memory (especially
if it's in a loop).
Let me know if that doesn't make sense.
Mark
Neil wrote:
> Hello All,
>
> If I have the following code:
>
> -------------------
> Dim MyRange As Range
>
> Set MyRange = "B19:I26"
> -------------------
>
> How can i get the Active worksheet (or any other worksheet) to select
that
> same range.
>
> ActiveSheet.Range(MyRange).Select
>
> wont work because Range expects 2 arguments.
>
> TIA,
>
> Neil.
Bookmarks