Loop through SELECTED sheets (set activewindow.selected sheets)
<p>My objective is to execute VBA code in selected sheets only.</p>

<p>I tried the following:</p>

<pre><code>1    Sub selectedsheet()
2        Dim sh As Worksheet
3        Dim selectedshs As Worksheets
4        
5        Set selectedshs = ActiveWindow.SelectedSheets
6        
7        For Each sh In selectedshs
8            MsgBox sh.Name
9        Next sh
10    End Sub
</code></pre>

<p>However in line 5, RunTime error 13 - Type Mismatch occurs.</p>

<p>Any help would be appreciated. Thanks!</p>