Sub 多表选择() Dim wks As Worksheet, shtCnt As Integer Dim arr() As Variant, i As Integer shtCnt = ThisWorkbook.Sheets.Count '取得工作表总数' ReDim arr(1 To shtCnt) '声明变量' For Each wks In ThisWorkbook.Sheets '在所有工作表中循环' If wks.Name Like "星期*" Then i = i + 1 arr(i) = wks.Name End If Next If i > 0 Then ReDim Preserve arr(1 To i) ThisWorkbook.Sheets(arr).Select '组合工作表' ActiveSheet.UsedRange.Select '选择区域' End If End Sub
讲解
通配符包括“”和“?”,“”表示任意字符;“?”表示单个字符