Unanswered: Excel VBA: How to ensure only one sheet selected
I have a Workbook with several sheets.
Sometimes more than one sheet will already be selected when it's opened.
I want to unprotect the Workbook using :
'Unprotect it if it's protected
If sht.ProtectContents = True Then
which works fine, PROVIDED that there is only one sheet selected.
So how do i make sure in my code that only 1 sheet is selected? I will never know which sheet(s) are selected in advance, so coding the selection of one particular sheet won't always work, because, if you select a sheet which is one of (say) three selected, all three remain selected, you just change which one is active.
Activating a sheet where multiple sheets are selected would not unselect the selected sheets.
ActiveWorkbook.Sheets(3).Activate 'This only activates a worksheet it will not ensure only one sheet is selected.
Using the Select statement will always select only one worksheet whether there is only one selected or multiple worksheets selected. Use Sheets(1).Select whenever the workbook is opened and you will ensure only one sheet is selected.