View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default define variable range

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