View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default VBA: Select Excel's Worksheet using wildcard

I think you'll have to look for a match another way:

Option Explicit
Sub testme01()

Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
If LCase(wks.Name) Like "week a??" Then
wks.Select
Exit For
End If
Next wks

End Sub

might work for you.



maxifire wrote:

Hi guys,

Sorry for the long post.

I'm having problem using wildcard to select the appropriate worksheet
in Excel.

This is what I have in the workbook.

In 1 workbook, I have 3 different worksheets and they are namely:

1. Week ABC
2. Week DEF
3. Week GHI

Say if I want to select the worksheet: 'Week ABC', I use either one of
the following codes to open the desired worksheet:

1. Sheets("Week A??").Select
2. Sheets("Week AB?").Select
3. Sheets("Week A*").Select
4. ..... and etc.

When I execute one of the aboved codes in VBA, I keep getting the
error: "Runtime error 9: The subscript is out of range."

Could someone please clarify is wildcard supported in the aboved
statements? If no, is there any way I can work around in order to make
it work? I need to automate the process of sheets selection as there
are many values in the sheet to calculate.

Any clue anyone?

Thanks.

Rgds

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson