![]() ThisWorkbook: ThisWorkbook cannot go wrong because it doesn’t matter which workbook is active.Active Workbook: Using Active in the coding may lead to many errors and confusion because we never know which workbook is active unless we specifically mention the workbook to activate before using the word Active Workbook.ThisWorkbook: ThisWorkbook is always the workbook where we are writing the code at the moment.If you have multiple opened workbooks and whichever the workbook is visible on your screen is considered as Active Workbook. Active Workbook: Active Workbook is not necessarily the workbook where we are writing the code at the moment.So, let me explain to you some of the differences. As a reader or a new learner, it is not easy to understand these two. ThisWorkbook in Excel VBAĪs I told at the beginning of the article, many coders use the words Active Workbook & ThisWorkbook very often in their VBA coding. From here on going forward in the procedure, we need not use the word “ThisWorkbook” instead, we can use the variable “Wb.” Active Workbook vs. Now the variable “Wb” is referenced to the workbook where we are writing the code at the moment. So I have used the “ThisWorkbook” reference. Since this is an object variable, we need to set the reference to the particular workbook. First, I have declared the variable as a Workbook object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |