Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Reference workbook with a certain word in the name
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:
Code:
Dim ws As Workbook If ws.Name Like "*count*" Then ws.Activate Any help is appreciated. Thanks! |
#2
|
|||
|
|||
Quote:
Code:
Dim ws As Workbook For Each ws In Workbooks If ws.Name Like "*Count*" then Windows(ws.Name).Activate Next |
#3
|
|||
|
|||
Quote:
Most people when they find the answer themselves just abandon the post and leave people working on it for them. |
#4
|
|||
|
|||
Thanks. I try to be courteous to everyone answering these. I also hate when I'm searching for an answer and the post is incomplete, so if I find an answer, I like to post it to benefit others.
|
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exporting Data to Word 2007 Using Reference to Word 11.0 Library | Excel Programming | |||
replace a word with another word through out workbook | Excel Worksheet Functions | |||
How to check workbook is already opened before passing the workbook obj to a subroutine in Word | Excel Programming | |||
word reference | Excel Programming | |||
word reference | Excel Programming |