cuddling101
New Member
- Joined
- Feb 10, 2009
- Messages
- 34
I am wanting to find out the worksheet name for a worksheet in another workbook. I have another function that does the reverse but I now can't find where I use it, in amongst 20+ spreadsheets, so this is very frustrating.
I have adapted the name to number spreadsheet, but all I am always getting is a #VALUE# error. I think it may be in the call but it could be in the code. Any help welcome, please.
Call reads -
A2 contains a number - in the first testing line it is 1.
Function reads -
With thanks in anticipation
Philip
Bendigo, Victoria
Australia
I have adapted the name to number spreadsheet, but all I am always getting is a #VALUE# error. I think it may be in the call but it could be in the code. Any help welcome, please.
Call reads -
Code:
=Sheet_Name_from_Sheet_Num("'[Johnson_Project_Patriarchal_Lines.xlsm]'",A2)
A2 contains a number - in the first testing line it is 1.
Function reads -
Code:
Function Sheet_Name_from_Sheet_Num(Workbook_Source As String, Worksheet_Number As Long) As String
Dim fWorkbook_Source As String
Dim fWorksheet_Number As Long
Dim fName As Long
Dim fExt_Workbook As Workbook
Dim fExt_Worksheet As Worksheet
fWorkbook_Source = Workbook_Source
fWorksheet_Number = Worksheet_Number
Set fExt_Workbook = Excel.Workbooks.Open(fWorkbook_Source)
Set fExt_Worksheet = fExt_Workbook.Worksheets(fWorksheet_Number)
fName = fExt_Worksheet.Name
Sheet_Name_from_Sheet_Num = fName
End Function
With thanks in anticipation
Philip
Bendigo, Victoria
Australia