ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing Workbook Name (https://www.excelbanter.com/excel-programming/330654-referencing-workbook-name.html)

Ken Hudson

Referencing Workbook Name
 
I have the following VBA code in which I am identifying the number of rows in
a workbook named "FileOpenNameLast." This name includes the full path of the
workbook and, therefore, my code deosn't work. Isn't there a simple way to
refer to the workbook name in my code?

NumRowsF832 =
Workbooks(FileOpenNameLast).Name.Sheets(1).Range(" A65536").End(xlUp).Row



--
Ken Hudson

Bob Phillips[_7_]

Referencing Workbook Name
 
When accessing an open file, you don't use the path.

Best way is to get the name when you open it.

--
HTH

Bob Phillips

"Ken Hudson" wrote in message
...
I have the following VBA code in which I am identifying the number of rows

in
a workbook named "FileOpenNameLast." This name includes the full path of

the
workbook and, therefore, my code deosn't work. Isn't there a simple way to
refer to the workbook name in my code?

NumRowsF832 =
Workbooks(FileOpenNameLast).Name.Sheets(1).Range(" A65536").End(xlUp).Row



--
Ken Hudson




Tom Ogilvy

Referencing Workbook Name
 
If xl2000 or later

Dim v as Variant
Dim sName as String
Dim FileOpenNameLast as String

' code that populates FileOpenNameLast with a fully qualified path name
v = Split(FileOpenNameLast,"\")
sName = v(ubound(v))
NumRowsF832 =
Workbooks(sName).Sheets(1).Range("A65536").End(xlU p).Row

--
Regards,
Tom Ogilvy


"Ken Hudson" wrote in message
...
I have the following VBA code in which I am identifying the number of rows

in
a workbook named "FileOpenNameLast." This name includes the full path of

the
workbook and, therefore, my code deosn't work. Isn't there a simple way to
refer to the workbook name in my code?

NumRowsF832 =
Workbooks(FileOpenNameLast).Name.Sheets(1).Range(" A65536").End(xlUp).Row



--
Ken Hudson





All times are GMT +1. The time now is 01:46 AM.

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