View Single Post
Old 02-09-2012, 03:39 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Range(Cell1,Cell2) Error on another workbook controlling some other workbook?

Sub test()

Dim book As Workbook
Dim sheet As Worksheet

Set book = Workbooks("test.xls")
Set sheet = book.Worksheets("Sheet1")


''' Application defined or Object defined error
sheet.Range(Cells(23, 2), Cells(47, 2)).Select
''' the below one didn't return an error
''' sheet.Range("B23:B47").Select

Set book = Nothing
Set sheet = Nothing
End Sub
When I run the Range(Cell1, Cell2).Select on a local worksheet, no problem.

But when I run the command on a local worksheet to select a range of cells on another worksheet, it returns the error (see the comment above)
Reply With Quote