Non-unique Worksheet Identifier? Perhaps?

Character7

New Member
Joined
Jul 15, 2017
Messages
7
Good morning. Quick question - doubt I will get the answer that I want, but this forum has proven me wrong in the past.

I am currently working on a project with 2 display / hud worksheets, 2 data worksheets, and 6 - 7 client worksheets. I want to find a way, without putting a "identifier" cell in the worksheet - to programmatically tell these sheets apart. In HTML - a page would have a "Unique" ID and a "Non-Unique" class, to which formatting could be applied to the page based on either reference. In Excel I can tell sheets apart by ID, whether they are protected / unprotected, and by whether they are hidden or not. I wanted to see if there was a parallel implementation of HTML's "Class" attribute that would allow for worksheets to be identified as a group. I am not talking about grouping sheets - that is not the desired outcome. I am looking to be able to quickly identify from a function which user-defined sheet "Type" I am looking at and executing code if that sheet meets that criteria.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Not exactly what you are looking for, but you could change the sheet codenames so that they have a specific prefix, lets say Main, Data & Cust
You could then sue code to look at the 1st 4 characters of the codename to tell which group they are in.
 
Upvote 0
Solution
Not exactly what you are looking for, but you could change the sheet codenames so that they have a specific prefix, lets say Main, Data & Cust
You could then sue code to look at the 1st 4 characters of the codename to tell which group they are in.
That solution could work. Use a 4 character sheet id [CLNT] - Client xxx, then grab the 6 characters and compare. Right on.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Glad to help & thanks for the feedback.
Wasn't aware of the rules pertaining to invalid characters in codenames, but in the end this solution works out perfectly. I went ahead and wrote it out, for others to use as an example. Thanks again.

VBA Code:
Function sheetModule()


    Application.ScreenUpdating = False

    Application.DisplayAlerts = False


    Dim protectedSheets As New Collection, workSheet As Worksheet, protectFilter As String


    protectedSheets.Add "Template"   


    prefexProtect = "CLNT" 


    For Each workSheet In ThisWorkbook.Worksheets


        If Left(workSheet.CodeName, 4) = prefexFilter And DoesItemExist(protectedSheets, workSheet.Name) = False Then


            ' This will be executed if the codename for sheet starts with CLNT and if sheet is not Protected.       


        End If


    Next workSheet


    Application.ScreenUpdating = True

    Application.DisplayAlerts = True


End Function
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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