Find the other workbooks name

M

MarkS

Hi,
I have two workbooks open to find the first workbooks name I use
ThisWorkBook.Name to problem is to find the other workbooks name. I need to
copy some data from the second workbook to the first workbook, the name of
the second workbook always changes

Thanks
 
C

Corey ....

Try:
Sub Button1_Click()
Dim WB As Workbook
For Each WB In Application.Workbooks
Debug.Print WB.Name
If WB.Name <> ThisWorkbook.Name Then
MsgBox "The other workbook names are : " & WB.Name
End If
Next
End Sub

Corey....
 
F

FSt1

hi
here is code that will assign the other workbook name to a variable call wbn.
this will work if you have ONLY 2 workbooks open. if you have a personal or
addin open also, then this will give you problems.
Sub listwb()
Dim wb As Workbook
Dim wbn As String
For Each wb In Application.Workbooks
If wb.Name <> ThisWorkbook.Name Then
wbn = wb.Name
MsgBox wbn 'test purposes only
End If
Next wb
End Sub

regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top