ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a worksheet tab name into a cell (https://www.excelbanter.com/excel-programming/369276-inserting-worksheet-tab-name-into-cell.html)

Lynn Bales

Inserting a worksheet tab name into a cell
 
I have a workbook with several worksheet tabs that have individual names on
them. I need to take the name and put it going down a column inside the
worksheet of that name for varying number of rows and I need to do this for
each worksheet.

Example:

Workbook A has sheets named
Lynn Bales, Joe Brown, Daphne Anderson

In worksheet Lynn Bales, I want the text "Lynn Bales" to go into column D to
the end of the rowed data. Then I want to do the same for Joe Brown's
worksheet and Daphne Anderson's worksheet.

Is this feasible? Thank you in advance!

Lynn

Jim Thomlinson

Inserting a worksheet tab name into a cell
 
In a standard code module (the same kind you get when you record a macro) you
can add the following function.

Public Function TabName() As String
Application.Volatile
TabName = Application.Caller.Worksheet.Name
End Function

This function can be used in a cell in a spreadsheet. For example on the
Lynn Bales sheet in the cells of column D add =TabName()

If the name of the sheet changes then this formula will automatically update
the next the the sheet is calculated.
--
HTH...

Jim Thomlinson


"Lynn Bales" wrote:

I have a workbook with several worksheet tabs that have individual names on
them. I need to take the name and put it going down a column inside the
worksheet of that name for varying number of rows and I need to do this for
each worksheet.

Example:

Workbook A has sheets named
Lynn Bales, Joe Brown, Daphne Anderson

In worksheet Lynn Bales, I want the text "Lynn Bales" to go into column D to
the end of the rowed data. Then I want to do the same for Joe Brown's
worksheet and Daphne Anderson's worksheet.

Is this feasible? Thank you in advance!

Lynn



All times are GMT +1. The time now is 11:10 PM.

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