reference tab name

kenpcli

Board Regular
Joined
Oct 24, 2017
Messages
129
I have several worksheets in my workbook, I need cell A2 to reference the tab or worksheet name of that worksheet. for example, worksheet 1 is called summary in cell a2 I need it to say summary, worksheet 2 is called ALB and need cell a2 in that worksheet to say ALB.

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
This formula will put the current sheet name in the cell of your choice. Isn't that what you wanted?
 
Upvote 0
You can also have an index of all worksheets in the workbook with hyperlinks to those sheets on your Summary sheet.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.



Code:
<code class="vb keyword">Sub</code> <code class="vb plain">CreateIndex()</code>



<code class="vb spaces">    </code><code class="vb keyword">Dim</code> <code class="vb plain">xAlerts </code><code class="vb keyword">As</code> <code class="vb keyword">Boolean</code>
<code class="vb spaces">    </code><code class="vb keyword">Dim</code> <code class="vb plain">I  </code><code class="vb keyword">As</code> <code class="vb keyword">Long</code>
<code class="vb spaces">    </code><code class="vb keyword">Dim</code> <code class="vb plain">xShtSummary </code><code class="vb keyword">As</code> <code class="vb plain">Worksheet</code>

<code class="vb spaces">    </code><code class="vb keyword">Dim</code> <code class="vb plain">xSht </code><code class="vb keyword">As</code> <code class="vb keyword">Variant</code>
<code class="vb spaces">    </code><code class="vb plain">xAlerts = Application.DisplayAlerts</code>
<code class="vb spaces">    </code><code class="vb plain">Application.DisplayAlerts = </code><code class="vb keyword">False</code>

<code class="vb spaces">    </code><code class="vb keyword">On</code> <code class="vb keyword">Error</code> <code class="vb keyword">Resume</code> <code class="vb keyword">Next</code>
<code class="vb spaces">    </code><code class="vb plain">Sheets(</code><code class="vb string">"Summary"</code><code class="vb plain">).Delete</code>

<code class="vb spaces">    </code><code class="vb keyword">On</code> <code class="vb keyword">Error</code> <code class="vb keyword">GoTo</code> <code class="vb plain">0</code>
<code class="vb spaces">    </code><code class="vb keyword">Set</code> <code class="vb plain">xShtSummary = Sheets.Add(Sheets(1))</code>

<code class="vb spaces">    </code><code class="vb plain">xShtSummary.Name = </code><code class="vb string">"Summary"</code>

<code class="vb spaces">    </code><code class="vb plain">I = 1</code>
<code class="vb spaces">    </code><code class="vb plain">Cells(1, 1).Value = </code><code class="vb string">"INDEX"</code>

<code class="vb spaces">    </code><code class="vb keyword">For</code> <code class="vb keyword">Each</code> <code class="vb plain">xSht </code><code class="vb keyword">In</code> <code class="vb plain">ThisWorkbook.Sheets</code>

<code class="vb spaces">        </code><code class="vb keyword">If</code> <code class="vb plain">xSht.Name <> </code><code class="vb string">"Summary"</code> <code class="vb keyword">Then</code>

<code class="vb spaces">            </code><code class="vb plain">I = I + 1</code>

<code class="vb spaces">            </code><code class="vb plain">xShtSummary.Hyperlinks.Add Cells(I, 1), </code><code class="vb string">""</code><code class="vb plain">, </code><code class="vb string">"'"</code> <code class="vb plain">& xSht.Name & </code><code class="vb string">"'!A1"</code><code class="vb plain">, , xSht.Name</code>

<code class="vb spaces">        </code><code class="vb keyword">End</code> <code class="vb keyword">If</code>
<code class="vb spaces">    </code><code class="vb keyword">Next</code>

<code class="vb spaces">    </code><code class="vb plain">Application.DisplayAlerts = xAlerts</code>

<code class="vb keyword">End</code> <code class="vb keyword">Sub

</code>3. Then press F5 key to execute this code, and the worksheet named “Summary” will include sheet names with hyperlinks.
<code class="vb keyword"></code>
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top