So, your macro opens all of the (5) workbooks in the folder.
You can still use the loop I've described and  use if/elseif/endif like:
 
Sub ListOpenWorkbooks()
    Dim wb As Workbook
    Dim file1, file2, file3, file4, file5
    For Each wb In Workbooks
        If (Left(wb.Name, Len("ForecastLastUpdated_ReferenceInformation_")) = _
                              "ForecastLastUpdated_ReferenceInformation_") Then
            file1 = wb.Name
        ElseIf (Left(wb.Name, Len("ForecastLastUpdated_")) = _
                                  "ForecastLastUpdated_") Then
            file2 = wb.Name
        ElseIf (Left(wb.Name, Len("filename3_")) = _
                                  "filename3_") Then
            file3 = wb.Name
        ElseIf (Left(wb.Name, Len("filename4_")) = _
                                  "filename4_") Then
            file4 = wb.Name
        ElseIf (Left(wb.Name, Len("filename5_")) = _
                                  "filename5_") Then
            file5 = wb.Name
        End If
    Next wb
End Sub
Keep in mind that especially with the filename in your example,
which name gets tested FIRST is important:
If you were to reverse the first two names, then the selection wouldn't work as 
intended.

Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------

 From: Nitin Balodi <nitinbal...@live.com>
>To: "excel-macros@googlegroups.com" <excel-macros@googlegroups.com> 
>Sent: Thursday, September 4, 2014 8:12 AM
>Subject: RE: $$Excel-Macros$$ Assign already open workbooks name to variables 
>using wildcard
>  
>
>
>Hi Paul,
>
>
>Thanks for your response. When the macro executes, it opens a folder and have 
>5 excel files in it. I am not sure which workbook will be assigned when I type 
>WorkBooks(1).activate or WorkBook(2).activate and so on.
>
>
>I want to assign a variable to specific workbook. Workbook names are not same 
>and will have timestamp of their extraction date and time.
>
>
>File1 = ForecastLastUpdated_*
>File2 = ForecastLastUpdated_ReferenceInformation*
>
>I hope it explains the criteria.
>
>
>Regards.
>
>
>Yours Sincerely,
>Nitin Balodi
>
>
>Date: Thu, 4 Sep 2014 03:33:36 -0700
>From: schreiner_p...@att.net
>Subject: Re: $$Excel-Macros$$ Assign already open workbooks name to variables 
>using wildcard
>To: excel-macros@googlegroups.com
>
>
>I'm not sure what you're expecting with the wildcard.
>
>perhaps you could give specific examples?
>
>The Workbook object contains all of the open workbooks. 
>You can loop through the Workbook object and save the filenames in a variable 
>or array, like:
>
>Option Explicit
>Sub ListOpenWorkbooks()
>    Dim wb As Workbook
>    Dim wbArray
>    
>    ReDim wbArray(0)
>
>    For Each wb In
 Workbooks
>        ReDim Preserve wbArray(UBound(wbArray) + 1)
>        wbArray(UBound(wbArray)) = wb.Name
>    Next wb
>
>End Sub
>
>if you're wanting to assign all filenames with a common name structure to a 
>single variable, then you're either going to have to use an array or 
>concatenate the names.
>
>also note:
>in your example:
>File1 =ForecastLastUpdated_*.xls*
>File2 = ForecastLastUpdated_ReferenceInformation*.xls*
>
>then name: 
>ForecastLastUpdated_ReferenceInformation*.xls*
>also is a match for:
>ForecastLastUpdated_*.xls*
>
>Paul
>-----------------------------------------
>“Do all the good you can,
>By all the means you can,
>In all the ways you can,
>In all the places you can,
>At all the times you can,
>To all the people you can,
>As long as ever you can.” - John
 Wesley
>-----------------------------------------
>
>
> From: Nitin Balodi <nitinbal...@live.com>
>>To: "excel-macros@googlegroups.com" <excel-macros@googlegroups.com> 
>>Sent: Thursday, September 4, 2014 1:58 AM
>>Subject: $$Excel-Macros$$ Assign already open workbooks name to variables 
>>using wildcard
>>  
>>
>>
>> 
>>Hi Experts,
>>
>>I require your help in another problem. I have n excel files already opened 
>>but want to assign file name to variables like
>>
>>File1 = ForecastLastUpdated_*.xls*
>>File2 = ForecastLastUpdated_ReferenceInformation*.xls*
>>
>>Highlighted in red are file name pattern and will be using these variables to 
>>perform specific functions for files. 
>>
>>Thanks for your help and support.
>>
>>
>>Regards.
>>
>>
>>Yours Sincerely,
>>Nitin Balodi 
-- 
>>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>>https://www.facebook.com/discussexcel
>> 
>>FORUM RULES
>> 
>>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not 
>>get quick attention or may not be answered.
>>2) Don't post a question in the thread of another member.
>>3) Don't post questions regarding breaking or bypassing any security measure.
>>4) Acknowledge the responses you receive, good or bad.
>>5) Jobs posting is not allowed.
>>6) Sharing copyrighted material and their links is not allowed.
>> 
>>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>>members are not responsible for any loss.
>>--- 
>>You received this message because you are subscribed to the Google Groups "MS 
>>EXCEL AND VBA MACROS" group.
>>To unsubscribe from this group and stop receiving emails from it, send an 
>>email to excel-macros+unsubscr...@googlegroups.com.
>>To post to this group, send email to excel-macros@googlegroups.com.
>>Visit this group at http://groups.google.com/group/excel-macros.
>>For more options, visit https://groups.google.com/d/optout.
>>
>>
>>     
>-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
> 
>-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
>
>
>    

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to