activate window with partial filename

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hi all,

I have the below code. I just want it to activate the open window with a partial filename however its not working. Any ideas? basically just activate the window with the partial name Version in it.

Jordan

VBA Code:
Windows("*Version.xlsx").Activate
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
How about something like this?
VBA Code:
Sub SelectWorkbook()

Dim wb As Workbook
Dim wb1 As Workbook

For Each wb In Application.Workbooks
    If InStr(1, wb.Name, "Version") > 0 Then
        Set wb1 = wb
    End If
Next wb

If wb1 Is Nothing Then
    MsgBox "Cannot find open file with that name"
Else
    wb1.Activate
End If

End Sub
 
Upvote 0
Solution
How about something like this?
VBA Code:
Sub SelectWorkbook()

Dim wb As Workbook
Dim wb1 As Workbook

For Each wb In Application.Workbooks
    If InStr(1, wb.Name, "Version") > 0 Then
        Set wb1 = wb
    End If
Next wb

If wb1 Is Nothing Then
    MsgBox "Cannot find open file with that name"
Else
    wb1.Activate
End If

End Sub
YOU DAH MAN JOE! THANKS AGAIN BUDDY!
Jordan
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,215,052
Messages
6,122,878
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top