Sub vba_activate_workbook()īy using the above code, you can specify a workbook name and this will first check for that workbook in all the open workbooks, and if it finds the workbook, it will activate it. To deal with this problem the best way is to check for the workbook name first (if it’s open or not) and then activate it. Sub vba_activate_workbook()Įnd Sub Check Before Activating a WorkbookĪs I said, when you try to activate a workbook that is not opened VBA will show you an error. Let’s say you have five workbooks open at the same time but you are working on the “Book1.xlsm”, so when you run the following code, it will activate the “Book1.xlsm”. You can refer to the workbook where you are writing code by using ThisWorkbook property.
0 Comments
Leave a Reply. |