looking for a way to ref / link tab name in a cell

Brooks70459

New Member
Joined
Jun 25, 2009
Messages
43
I hope that I am explaining this correctly.

I am about to audit a factory. I am building a standard form in an Excel workbook to collect the data. I will initially have fifteen workbooks. Each workbook will represent a specific area in the factory. Each workbook has about fifty worksheets, each a different (sub)assembly.

What I would like to do is make a template that would have a function that would populate a cell in (let's say Column G) with its respective worksheet tab name. It would be nice to this automatically occur when data is entered into Col. C the same row.

Your help is appreciated.
 
Hi Brooks70459,

If you want to take a look, I put together an example WB named
"Enter In C - TabName In G.xls" which you can download from:

http://www.box.net/shared/yyuzgkly1r

If you enter something in a cell in Column C, the Tab name will appear in Column G in the same row.

ColinKJ
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I finally opted for this solution. This worked great. I found the Private / Sub area to be very powerful and I see the potential in using it.

Thanks (both of you) :biggrin:





Hi Brooks70459,

If you Right Click on the Tab, then select View Code.

You should see a drop down Box with (General) showing in it. Click in there, then select Worksheet.

This should show you the Private Sub "Worksheet_SelectionChange"

You should now see a drop down Box with "SelectionChange" in it. Click in to this, then select "Change".

This should give you the "Private Sub Worksheet_Change".

Just paste the code in here.

ColinKJ
 
Upvote 0
Colin,

Can I do the same thing using filename (parsing-out the .xls) in lieu of tab name?

I want to add it to the code if possible?

Good luck and thanks :rolleyes:



Hi Brooks70459,

If you Right Click on the Tab, then select View Code.

You should see a drop down Box with (General) showing in it. Click in there, then select Worksheet.

This should show you the Private Sub "Worksheet_SelectionChange"

You should now see a drop down Box with "SelectionChange" in it. Click in to this, then select "Change".

This should give you the "Private Sub Worksheet_Change".

Just paste the code in here.

ColinKJ
 
Upvote 0
Try replacing the code you have with this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then Cells(Target.Row, 7) = ThisWorkbook.Name
End Sub

ColinKJ
 
Upvote 0
That worked great Colin; Thanks. :cool: Would I add a trim right function here, or would it be cleaner to simply add it as a seperate (hand driven) macro?

I want to remove the .xls extention.

-Brooks
 
Upvote 0
Just use
Code:
If Target.Column = 3 Then Cells(Target.Row, 7) = LEFT(ThisWorkbook.Name,LEN(ThisWorkBook.Name)-4)
You can also use FullName to get the path!

lenze
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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