show/hide sheet based on name

kachaloo

New Member
Joined
Jan 18, 2011
Messages
22
Office Version
  1. 2016
Platform
  1. Windows
Hello all
I am using this code in every sheet which changes the sheet name based on cell value. which works fine. However one Problem is, it only changes the name when a a user click anywhere on the sheet.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Set Target = Range("F1")
    If Target = "" Then Exit Sub
    On Error GoTo Badname
    ActiveSheet.Name = Left(Target, 31)
    Exit Sub

End Sub
My question is , I do not want the user to see the sheet if the sheet name is Only between "1-10"

Cell "F1" get name from another sheet, If there is employee name there,
The sheet names are like

  1. "1 Firstname Surname"
  2. "2 Firstname Surname"
  3. .
  4. .
  5. .
  6. .
  7. .
  8. .
  9. .
  10. "10 Firstname Surname"

When there is no employee in another teh F1 value changes to only to number and obviously sheet names are then.


  1. "1"
  2. "2"
  3. .
  4. .
  5. .
  6. .
  7. .
  8. .
  9. .
  10. "10"

I need help in writing an additional code to the above which does the following.

  1. Change sheet names without go into that sheet and click anywhere there which changes the name.
  2. Show only those sheets where the name are like "1 Firstname Surname", "2 Firstname Surname" NOT only 1,2,...10
Thanks in advance.

Kachaloo
Apologies for any mistakes or not clearly explaining my point.
English is my 3rd language..
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,459
Messages
6,124,945
Members
449,198
Latest member
MhammadishaqKhan

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