Reference workbook with a certain word in the name
KeriM wrote:
I need to reference an open workbook in my code but the name changes
periodically; however, it always has the word "count" in it. Is there a
way to reference a workbook by a certain word in the name? This is what
I have so far:
[snip]
I think I need a "set" somewhere, but I'm not sure what to "set" it as.
Try something like this:
For Each ws In Workbooks
If InStr(1, ws.Name, "count", vbTextCompare) Then
'...whatever you need to do to ws...
'If there's only one wb named *count* then finish with this:
Exit For
End If
Next
--
- How anticlimatic.
- Well, we're out of real estate!
|