More thorough and effective practice fully references the range reference information, even if you are working on a local sheet. Then the code can
- be more easily adapted
- easier to read and
- less likely to have problems
code
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Cells(1, 1) = 10
preferable
Cells(1, 1) = 10
, (1), Workbook ThisWorkbook. , addin, ThisWorkbook .
. - , Cells.
Sheet1 Sheet2,
Set ws = Sheets(2)
Set rng1 = ws.Range(Cells(1, 1), Cells(10, 10))
Set ws = Sheets(2)
Set rng1 = ws.Range(ws.Cells(1, 1), ws.Cells(10, 10))
, Worksheet, ( ActiveSheet).