View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default How to multi-select worksheets?

Hi OKLover,

So select all the sheets whose names include the letter 'a2, try:

'============
Sub ATester01()
Dim Sh As Worksheet

For Each Sh In ActiveWorkbook.Worksheets
If InStr(1, Sh.Name, "a") Then
Sh.Select False
End If
Next Sh
End Sub
'<<============


---
Regards,
Norman


"OKLover" wrote in message
...
Thanks, Norman and Bob

But what i need is loop current workbook to filter and select some
worksheets.

ex:

I have five worksheets: sheet1, sheet2, sheet_aa, sheet_ba, sheet_ca

For Each tSheet In thisworkbook.worksheets
If Instr(tSheet.Name, "a") Then
'** Select all of the worksheet which name include the 'a'
End If
Next

What i can do?



"OKLover" wrote:

Hi, All

I have multiple worksheets, when i write below VBA code, it's ok:

Sheets(Array("Sheet1", "Sheet2",....)).Select

But when i assign it to a variable:

Sub Macro1()
Dim str As String
str = "Sheet1" & Chr(44) & "Sheet2"
Sheets(Array(str)).Select
End Sub

It seems doesn't work, what i can do?


Thanks