ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find the other workbooks name (https://www.excelbanter.com/excel-programming/412093-find-other-workbooks-name.html)

MarkS

Find the other workbooks name
 
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

Corey ....[_2_]

Find the other workbooks name
 
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....
"MarkS" wrote in message
...
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




FSt1

Find the other workbooks name
 
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

"MarkS" wrote:

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



All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com