ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping only through selected sheets (https://www.excelbanter.com/excel-programming/427008-re-looping-only-through-selected-sheets.html)

Paul S

Looping only through selected sheets
 


"Mike H" wrote:

Hi,

Try this

Dim sh As Object
For Each sh In ActiveWindow.SelectedSheets
MsgBox sh.Name
'do things
Next

Mike

"Paul S" wrote:

What is the VBA code to loop through only the selected sheets in a workbook?
That is if I have a workbook contain sheets A, B, C, D, and E and if I have
selected multiple sheets, say A, B and E, how do I write code that will
perform operations only on those sheets (A, B, and E)?



All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com