Hi all,
I have the following code snippet, which is genereating the always lovely "Application-defined or object-defined error" message.
Please help if you know what I am doing wrong!
Thx,
Nolan
note that, in this particular context I do have a sheet named WBS, but it is *not* active. If I run this code when WBS is active, it works fine. I am trying to avoid having to activate the sheet in order to define a range within that sheet.
I am working with Excel 2010.
Any help is much appreciated!
I have the following code snippet, which is genereating the always lovely "Application-defined or object-defined error" message.
Please help if you know what I am doing wrong!
Thx,
Nolan
Code:
Sub setRange()
Dim srcSht As Worksheet, srcRng As range
Set srcSht = Worksheets("WBS")
Set srcRng = ActiveWorkbook.Worksheets("WBS").range(Cells(2, 2), Cells(21, 3))
End Sub
note that, in this particular context I do have a sheet named WBS, but it is *not* active. If I run this code when WBS is active, it works fine. I am trying to avoid having to activate the sheet in order to define a range within that sheet.
I am working with Excel 2010.
Any help is much appreciated!