Hi,
I need a VBA module or code that will find all sheets in the current workbook that contain the word "Section"
Then pass them into an array and select them
Sheets(Array("First Sheet", "Second Sheet")).Select
From here I will perform some actions but this is one part I am struggling with
Thinking of writing it like this, but need help forming the array element to store each sheet name that meets the instr criteria (or should I be using LIKE ?)
Then from here I need a logic test, if >0 then add the ws.name to an array...or redim an existing array. So eventually will have an array full of sheet name that meet the sht criteria...then this can be passed to the Sheets(Array()).Select statement?
I need a VBA module or code that will find all sheets in the current workbook that contain the word "Section"
Then pass them into an array and select them
Sheets(Array("First Sheet", "Second Sheet")).Select
From here I will perform some actions but this is one part I am struggling with
Thinking of writing it like this, but need help forming the array element to store each sheet name that meets the instr criteria (or should I be using LIKE ?)
Code:
Public Function SelectSheets(sht as String, Optional wbk as Workbook)
Dim ws as Worksheet
For each ws in wbk.sheets
If InStr(1,ws.name,sht)
Then from here I need a logic test, if >0 then add the ws.name to an array...or redim an existing array. So eventually will have an array full of sheet name that meet the sht criteria...then this can be passed to the Sheets(Array()).Select statement?
Last edited: