tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
My workbook has two worksheets, Sheet1 and Sheet2.
If I put this code in a standard module, it's fine:
but why is it when I put it in Sheet2, it fails:
with this message:
Thanks
EDIT SORTED:
Need to fully qualify, so
If I put this code in a standard module, it's fine:
Code:
Sub SetRange()
Dim rng As Range
Set rng = Range(Sheet1.Cells(1, 1), Sheet1.Cells(100, 1))
End Sub
but why is it when I put it in Sheet2, it fails:
Code:
Private Sub Worksheet_Activate()
Dim rng As Range
Set rng = Range(Sheet1.Cells(1, 1), Sheet1.Cells(100,1))
End Sub
with this message:
Code:
Method 'Range' of object '_Worksheet' failed
Thanks
EDIT SORTED:
Need to fully qualify, so
Code:
Set rng = Sheet1.Range(Sheet1.Cells(1, 1), Sheet1.Cells(100,1))
Last edited: