ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Subscript out of Range on Range reference (https://www.excelbanter.com/excel-programming/276945-re-subscript-out-range-range-reference.html)

Tom Ogilvy

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






All times are GMT +1. The time now is 02:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com