ActiveWorkbook refers to the workbook that is currently active (i.e. The workbook with the selected cells).
ThisWorkbook refers to the workbook in which the code that is currently running is located.
ThisWorkbook can also be (and in most cases is) the ActiveWorkbook.
If open and activate other workbooks using code from another workbook they become the ActiveWorkbook and the workbook that contains the code that opens and activates the other workbooks is always ThisWorkbook.
In your code, if you use ThisWorkbook you will only be able to count the worksheets in the workbook that is running that procedure. If you use ActiveWorkbook (as you have), then you will be able to count the worksheets in another workbook (if it is activated).
Depending on what you want to do, you can use either ThisWorkbook or ActiveWorkbook
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.