View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Subscript out of Range on Range reference

Subscript out of range means you don't have a worksheet named "Sheet1"

In the second example, subscript out of range would mean the same - no
Sheet1, but eventually, if you clear that up, you will get an error if the
named sheet is not the activesheet.
With Worksheets("Sheet1")
set rng = .Range(.Cells(1, 1), .Cells(5, 5))
End With

--
Regards,
Tom Ogilvy




paul reed wrote in message
...
Hello,

I have spreadsheet and I am building a macro in the VB Editor. Whenever I
try to reference a range likes this:

Worksheets("Sheet1").Range("A6:D10")

or like this...

Worksheets("Sheet1").Range(Cells(1, 1), Cells(5, 5))

I get a subscript out of range...there is definitely data in those cells

for
sure. I am do a lot of programming...but this one is not obvious to me for
some reason.

Thanks in advace,

Paul