Hello LiLi1,
When referencing an object, like a Range, on a worksheet, if the object is not qualified then the active sheet is assumed.
Let's say that "Sheet3" is the ActiveSheet.
This will clear the contents of "A1:A10" on "Sheet3". If the user changes sheets before the macro is run to "Sheet1" Then he macro will clear the contents of the cells "A1:A10" on "Sheet1".
To ensure that only the cells "A1:A10" on "Sheet3" are cleared, the code can be written this way. By making the code reusable, your code will be easier to read, maintain, and provide you with more options. If you perform a function 3 or more times in your code, you should consider making it a separate procedure.
Bookmarks