PC Review


Reply
Thread Tools Rate Thread

define variable range

 
 
Ray
Guest
Posts: n/a
 
      16th Aug 2007
Hello -

I'm modifying some code from Dave McRitchie to create a TOC and need
some help ...

I've set up an InputBox where users select a cell, which should become
the upper-left corner of the TOC -- this cell is called 'StartCell'.
The code goes on to establish the range (rg), which is seven columns
by the number of sheets in the book. For example:
StartCell = A2
ActiveWorkbook.Sheets.Count = 10
RESULT should be that rg = A2:G12

Here's the code with my latest attempt to make it happen:
Set rg = Range(StartCell, Cells(ActiveWorkbook.Sheets.Count,
StartCell.Offset(0, 7)))

what am I doing wrong?

tia, ray

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      16th Aug 2007
Set rg = StartCell.Resize(ActiveWorkbook.Sheets.Count,7)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ray" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello -
>
> I'm modifying some code from Dave McRitchie to create a TOC and need
> some help ...
>
> I've set up an InputBox where users select a cell, which should become
> the upper-left corner of the TOC -- this cell is called 'StartCell'.
> The code goes on to establish the range (rg), which is seven columns
> by the number of sheets in the book. For example:
> StartCell = A2
> ActiveWorkbook.Sheets.Count = 10
> RESULT should be that rg = A2:G12
>
> Here's the code with my latest attempt to make it happen:
> Set rg = Range(StartCell, Cells(ActiveWorkbook.Sheets.Count,
> StartCell.Offset(0, 7)))
>
> what am I doing wrong?
>
> tia, ray
>



 
Reply With Quote
 
Ray
Guest
Posts: n/a
 
      16th Aug 2007
Well THAT was easy ... guess I shoulda known that!

thanks Bob!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define variable range input for SUM() function JeffC Microsoft Excel Worksheet Functions 8 16th May 2009 03:54 AM
Define a range with a variable troy_lee@comcast.net Microsoft Excel Discussion 3 24th Mar 2009 08:38 PM
Define Range Name with variable row value wayliff Microsoft Excel Programming 2 17th Jan 2006 03:23 PM
Define variable range acberry Microsoft Excel Programming 2 12th May 2004 02:44 PM
Define variable range acberry Microsoft Excel Worksheet Functions 0 12th May 2004 09:31 AM


Features
 

Advertising
 

Newsgroups
 


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