ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extracting Sheet Name (https://www.excelbanter.com/excel-programming/285193-extracting-sheet-name.html)

Nick H[_4_]

Extracting Sheet Name
 
I'd like to create a worksheet function that will take as input a cell
reference or range, and will return the name of the worksheet that the input
cell/range is on. For example, I would like to be able to enter a function
with this general name/form:

=Sheetname('Sheet1'!A1)

and get the following text:

Sheet1

Thanks for any help!

Nick




Chip Pearson

Extracting Sheet Name
 
Nick,

You can use a VBA function like the following:

Function GetSheetName(R As Range) As String
GetSheetName = R.Worksheet.Name
End Function

Then, call it from a worksheet cell with
=GetSheetName(Sheet3!A1)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Nick H" wrote in message
...
I'd like to create a worksheet function that will take as input

a cell
reference or range, and will return the name of the worksheet

that the input
cell/range is on. For example, I would like to be able to

enter a function
with this general name/form:

=Sheetname('Sheet1'!A1)

and get the following text:

Sheet1

Thanks for any help!

Nick







All times are GMT +1. The time now is 05:42 PM.

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