Glaswegian
06-04-2009, 06:26 AM
Hi again
I'm trying to search through sheet names in a workbook, looking for particular sheets which I'll copy to another workbook. I'm having a bit of a problem with trying to find the sheet names.
Each workbook will have around 20-25 sheets, but I'm only interested in sheet names that match a specific pattern.
The sheets are named as the original sheet name plus the date and time the sheet was saved. In the examples below, x represents any letter and 9 represents any digit. However, the original sheet name could be between 3 and 7 characters.
xxxx 99 xxx 99 - 99.99
xxxxxx 99 xx 99 - 99.99
and so on. After I identify the sheet, I take a copy and do some other stuff.
For Each sht In Workbooks(myFile).Worksheets
If sht.Name Like "[A-Z] ##" Then
sht.Copy After:=Workbooks("DCS July 2009.xls").Sheets(1)
End If
Next sht
It's the pattern I can't get right and I've tried several variations - hopefully someone will put me out my misery here...
I'm trying to search through sheet names in a workbook, looking for particular sheets which I'll copy to another workbook. I'm having a bit of a problem with trying to find the sheet names.
Each workbook will have around 20-25 sheets, but I'm only interested in sheet names that match a specific pattern.
The sheets are named as the original sheet name plus the date and time the sheet was saved. In the examples below, x represents any letter and 9 represents any digit. However, the original sheet name could be between 3 and 7 characters.
xxxx 99 xxx 99 - 99.99
xxxxxx 99 xx 99 - 99.99
and so on. After I identify the sheet, I take a copy and do some other stuff.
For Each sht In Workbooks(myFile).Worksheets
If sht.Name Like "[A-Z] ##" Then
sht.Copy After:=Workbooks("DCS July 2009.xls").Sheets(1)
End If
Next sht
It's the pattern I can't get right and I've tried several variations - hopefully someone will put me out my misery here...