Re: syntax - range name as a variable
- From: Dave Peterson <petersod@xxxxxxxxxxxxxxxx>
- Date: Fri, 04 Aug 2006 13:09:01 -0500
You can only select a range if the work*** that owns the range is active.
And you can only select a work*** if the workbook that owns the work*** is
active.
So you can pepper your code with
workbooks("book1.xls").activate
workbooks("book1.xls").worksheets("sheet1").select
workbooks("book1.xls").worksheets("sheet1").range("range_01").select
or use
application.goto _
workbooks("book1.xls").worksheets("sheet1").range("range_01"), _
scroll:=true '?
======
And depending on where your code is (is it behind a work***?), you could have
the problem because an unqualified range (range("range_01") belongs to the
work*** that holds the code.
And that might not be where the range really is (and it blows up real good).
Peter Morris wrote:
I can select a named range like so :
range ("range_01").select
this works. but I want to make the selected range a variable like this:
range_string = "range_01"
range (range_string).select
This gives me error messages "method range of object global failed"
What is the correct syntax for doing this?
--
Dave Peterson
.
- References:
- syntax - range name as a variable
- From: Peter Morris
- syntax - range name as a variable
- Prev by Date: Re: VLOOKUP and VBA
- Next by Date: Re: Identifying value in a cell knowing R1C1 naming
- Previous by thread: Re: syntax - range name as a variable
- Next by thread: Re: Verify user input box is a Month End Date
- Index(es):