Reference or second name to identify a group of worksheets - excel

I want to add a second name (but hidden) to each Excel sheet.
Each group of worksheets is related to a different project.
Can I add the project name with VBA? I have two Listbox where you can choose a project name and I want to retrieve all the worksheet names related to the selected project.

Related

Can we batch rename excel variable names?

Image you have an excel sheet, with names as variables for formulas, references, etc. (all viewable the Names Manager).
You want to create clones of this sheet, and add them as separate sheets to another workbook.
However, the names will conflict.
E.g. FirstColumnTitle will be the same for each sheet.
Excel seems to latch the basic function to batch rename variable names in the Names Manager, so the same name can be renamed (e.g. append ‘_sheet1’ to FirstColumnTitle making it ‘FirstColumnTitle_sheet1’).
How would one go about this?
I tried Names Manager, and a VB Macro (link below) that was supposed to work (but only renamed a single variable).
Sub RenameCells()
Dim n As Name
For Each n In ThisWorkbook.Names
n.Name = "KUTOOLS_" & n.Name
Next n
End Sub
I can manually change the names one by one, but… what if there are hundreds of names on a sheet that will be cloned to the same workbook a handful of times?
Example: the sheet/worksheet is a loan amortization template. In the Template, it has names such as “LoanAmount” which refers to the cell where the loan amount is entered, and “LoanInterestRate” referring to the cell sign the APR.
If I try to copy that whole worksheet into another workbook twice (two different copies of the loan worksheet in two tabs in one workbook) the variable names (found in Names Manager) conflict with one another and end up interfering with one another or blocking calculations/functionality in one or the other worksheet (if they have different values.)
How to reproduce the problem (that I'm trying to solve):
Create a new spreadsheet from the "Loan Amortization Schedule" template,
then create a copy of that sheet a couple times to the same workbook (or another).
Now set a loan balance, APR, loan term, and payments per year (make it different for each sheet such that the number of payments should be different).
Notice that in the second (and third and fourth) sheet, the result for "Actual Number of Payments" for each sheet is whatever the value is for the first sheet. Open Names Manager, and the name for each indicates that its scope is only for the appropriate sheet, yet somehow sheet1's ActualNumberOfPayments reference name is referred to in the other sheets (even though their respective ActualNumberOfPayments appropriately refers to the other reference names in their own sheet only).

Excel create an Index on the first sheet with links to subsequent sheets

I have a Workbook with 12 Worksheets. The first Worksheet is the Index, the 11 other sheets contain data relative the index. This Workbook references a file tree structure, what I am trying to do is link all Folder names to their respected Worksheet. I have labelled these folders as 'Folder 1, Folder 2' etc. In reality the folder names are all unique.
The table below is the folder tree.
I need to name the worksheets based on their breadcrumbs. So For example Folder 3 Would be
Folder 1>Folder 2>Folder 3
With the limit being set as 31 characters, Any directories 6 deep with long names wouldn't fit. So I have the table below.
How would I go about doing this? The worksheets are in order, I just need to batch rename based on their path and link to the first table, so when they click on Folder 8, they will hit tab F1.F6.F8
This seems to be a potential duplicate of Excel - Hyperlink to a worksheet which name is found in a cell over at Stackoverflow Superuser
This answer shows how to use the Hyperlink function in excel to take a value from a cell (your worksheet name column) and using this to link to another tab
=HYPERLINK(CONCATENATE("#", [cellcontainingthetabname], "!A1"), [textyouwishtodisplay])

Using external copied data as the sheet name

I get data segmented into files by individual. I download the files and copy the individual's name. I want to create a macro that makes the sheet name what the copied individual's name is and after formatting it export the sheet to a PDF that is named what the sheet name is.
I've created the macro for the formatting already, just having trouble with the copied name part.

How to find the index number of renamed sheets in excel-vba

I have about 8 sheets in a workbook with different names. Is there a way using VBA to activate one ore more of these sheets based on their index number? For example I have sheets named, "Month", "Name", "Age" etc... how can I find their index number?
Try this
Sheets("<sheet Name>").Index
If you want to get code name
Sheets("<sheet Name>").codename
It’s possible for the sheet name to be different from the code name. When you create a sheet, the sheet name and code name are the same, but changing the sheet name doesn’t change the code name, and changing the code name (using the Properties window in the Visual Basic Editor) doesn’t change the sheet name.
To get a sheet's index:
sheets("month").index
To activate by index:
sheets(5).activate

Excel VBA worksheet.names vs worksheet.range

I have created a defined name/range on a worksheet called bob, pointing to a single cell. There are a number of other name/ranges set up on this worksheet, which I didn't create. All the number/ranges work perfectly except for mine.
I should be able to refer to the contents of this cell by using either of the following statements:
(worksheet object).Names("bob").RefersToRange.Value
(worksheet object).Range("bob").Value
However, only the second statement, referring to the Range works for some reason. The first one can't find the name in the Names list.
My questions are:
What is the difference, if any, between a Name and a Range?
Is this something to do with the global/local scope of my name/range?
How were the other name/ranges created on the sheet so that they appear in both the worksheets Name and Range list?
Yes, you are right.
Names can be local (belong to a worksheet) and global (belong to a workbook).
(worksheet object).Names("bob") will only find a local name. Your name is obviously global so you could access it as (worksheet object).Workbook.Names("bob").RefersToRange.
The "other names" are probably local. They only appear in the ranges list when their parent sheet is active (check that out). To create a local name, prepend it with the sheet name, separated by a '!': 'My Sheet Name'!bob.
I don't know how to do it with code, but if you go to the Name Manager Under the Formula tab group in the Ribbon in Excel 2007, you can create names and choose their scope.

Resources