Selecting a Workbook using partial name

Raj999

New Member
Joined
Dec 16, 2014
Messages
7
Hi All,

Imagine I have 3 Workbooks open with File names ABC12345, DEF54321, GHI00000. These partial names are present in a column of an excel workbook say XYZ (ABC in A1 cell, DEF in A2 cell, GHI in A3 Cell)

I want a macro which can select(or activate) the respective workbook by reading the contents of cells one by one. Please help...!!!
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi. Welcome to the board :).

Would some code like this help you to get started?
Code:
Option Explicit
Public Sub ActivateWorkbook()
    Dim matchString As String
    Dim wb As Workbook
    Dim cell As Range
    
    Do 'dummy loop
    For Each cell In ThisWorkbook.Sheets("Sheet1").Range("A1:C1") 'Change as required
    For Each wb In Application.Workbooks
        If InStr(1, wb.Name, cell.Value) > 0 Then
            wb.Activate
            Exit Do
        End If
    Next wb
    Next cell
    Loop Until True
End Sub

/AJ
 
Upvote 0
Thanks a lot AJ. It worked as I wanted to.

One more small query : I need to concatenate value of two cells (say A1 and B1) with "-" in between them. Please help me with this.

I am trying this : ActiveCell.Formula = "=CONCATENATE(A2,"-",B2)" but no luck.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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