Gå til hovedindhold

Hvordan indstilles adgangskode for at beskytte skjult ark i Excel?

Hvis du har en projektmappe, der indeholder nogle vigtige skjulte regneark, og ikke tillader andre at skjule dem. Nu skal du indstille en adgangskode for at beskytte de skjulte regneark fuldstændigt, når andre brugere viser dem, skal de indtaste adgangskoden. Har du nogen måder at håndtere denne opgave hurtigt og nemt i Excel?

Indstil adgangskode for at beskytte skjulte ark med VeryHidden-funktionen

Indstil adgangskode for at beskytte skjult ark med VBA-kode

Beskyt flere regneark på én gang med Kutools til Excel


Indstil adgangskode for at beskytte skjulte ark med VeryHidden-funktionen

Normalt kan du bruge VeryHidden-funktionen til først at skjule regnearkene og derefter indstille en adgangskode til dem. Benyt følgende trin:

1. Åbn din projektmappe, og hold den nede Alt + F11nøgler til at åbne Vinduet Microsoft Visual Basic til applikationer.

2. I Vinduet Microsoft Visual Basic til applikationerklik Specifikation > Projekt Explorer , Egenskaber vindue to vise deres ruder.

doc-protect-skjult-ark-01

3. Og så i Projekt-VBAProjekt vælg det regneark, du vil skjule, og i Ejendomme skal du klikke på rullelisten fra Synlig sektion at vælge xlSheetMegetSkjult mulighed, se skærmbillede:

doc-protect-skjult-ark-02

4. Når du har gjort regnearket meget skjult, kan du indstille en adgangskode for at beskytte det. I Vinduet Microsoft Visual Basic til applikationerklik indsatte > Moduler for at åbne et tomt modul, og klik derefter på Værktøjer > VBAProjektegenskaber, se skærmbillede:

doc-protect-skjult-ark-03

5. Så i poppet ud VBAProject-projektegenskaber dialogboksen, klik Beskyttelse fanebladet, og tjek derefter Lås projekt til visning boks, til sidst skal du indtaste og bekræfte adgangskoden i Adgangskode for at se projektegenskaber sektion, se skærmbillede:

doc-protect-skjult-ark-04

6. Klik derefter på OK for at afslutte denne dialog og lukke Vinduet Microsoft Visual Basic til applikationer.

7. Gem projektmappen som Excel-makroaktiveret projektmappe format og luk det for at få adgangskodebeskyttelsen til at træde i kraft.

doc-protect-skjult-ark-05

8. Næste gang, når du åbner denne projektmappe og vil gøre de meget skjulte ark synlige, bliver du bedt om at indtaste en adgangskode. Se skærmbillede:

doc-protect-skjult-ark-06


Demo: Indstil adgangskode for at beskytte skjulte ark


Indstil adgangskode for at beskytte skjult ark med VBA-kode

For at indstille en adgangskode til at beskytte de skjulte ark kan jeg også tale om en VBA-kode til dig.

1. Skjul et regneark, som du vil beskytte.

2. Hold nede ALT + F11 nøgler til at åbne Vinduet Microsoft Visual Basic til applikationer.

3. Vælg derefter ThisWorkbook fra venstre Projekt Explorer, dobbeltklik på den for at åbne Moduler, og kopier og indsæt derefter følgende VBA-kode i det tomme modul:

VBA-kode: Indstil adgangskode for at beskytte skjult ark

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
xSheetName = "Sheet1"
If Application.ActiveSheet.Name = xSheetName Then
    Application.EnableEvents = False
    Application.ActiveSheet.Visible = False
    xTitleId = "KutoolsforExcel"
    response = Application.InputBox("Password", xTitleId, "", Type:=2)
    If response = "123456" Then
        Application.Sheets(xSheetName).Visible = True
        Application.Sheets(xSheetName).Select
    End If
End If
Application.Sheets(xSheetName).Visible = True
Application.EnableEvents = True
End Sub

doc-protect-skjult-ark-07

Bemærk: I ovenstående kode, Sheet1 af xSheetName = "Ark1" script er det skjulte regnearknavn, som du vil beskytte, og 123456 i Hvis svar = "123456" Så script er den adgangskode, du har angivet til det skjulte ark. Du kan ændre dem til dit behov.

4. Nu, når du vil vise det skjulte ark, vises en hurtigboks, der giver dig mulighed for at indtaste adgangskoden. Og dette promptfelt vises hver gang, når du klikker for at vise det skjulte ark.

doc-protect-skjult-ark-08


Beskyt flere regneark på én gang med Kutools til Excel

Hvis du normalt vil beskytte flere valgte eller alle regneark i en projektmappe på en gang, skal du manuelt beskytte en efter en manuelt i Excel. Men hvis du har Kutools til Excel, Med Beskyt regneark værktøj, kan du beskytte dem med et enkelt klik.

Kutools til Excel : med mere end 300 praktiske Excel-tilføjelsesprogrammer, gratis at prøve uden begrænsning på 30 dage

Efter installation Kutools til Excelskal du gøre som følger:

1. Klik Kutools Plus > Beskyt regneark, se skærmbillede:

2. I Beskyt regneark i dialogboksen, vises alle regneark i projektmappen i listeboksen. Vælg de regneark, du vil beskytte. Se skærmbillede:

doc-protect-skjult-ark-010

3. Og klik derefter på OK, i den følgende dialogboks, skal du indtaste din adgangskode, indtaste den igen, og klik derefter på OK, vises en anden hurtigboks for at minde dig om, hvor mange regneark der er beskyttet.

doc-protect-skjult-ark-011

4. Klik derefter på OK for at lukke dialogerne, og alle regnearkene i projektmappen er beskyttet med den samme adgangskode.

Bemærk: Hvis du vil fjerne beskyttelsen af ​​alle regnearkene på én gang, skal du bare klikke Kutools Plus > Fjern beskyttelse af regneark, og skriv din adgangskode for at annullere beskyttelsen.

 Download og gratis prøveversion Kutools til Excel nu!


Relaterede artikler:

Hvordan beskyttes flere regneark på én gang i Excel?

Hvordan indstilles en adgangskode for at beskytte projektmappen?

Hvordan beskyttes / låses VBA-kode i Excel?

Bedste kontorproduktivitetsværktøjer

🤖 Kutools AI Aide: Revolutionér dataanalyse baseret på: Intelligent udførelse   |  Generer kode  |  Opret brugerdefinerede formler  |  Analyser data og generer diagrammer  |  Aktiver Kutools funktioner...
Populære funktioner: Find, fremhæv eller identificer dubletter   |  Slet tomme rækker   |  Kombiner kolonner eller celler uden at miste data   |   Runde uden formel ...
Super opslag: VLookup med flere kriterier    Multiple Value VLookup  |   VOpslag på tværs af flere ark   |   Fuzzy Lookup ....
Avanceret rulleliste: Opret hurtigt rulleliste   |  Afhængig rulleliste   |  Multivælg rulleliste ....
Column Manager: Tilføj et bestemt antal kolonner  |  Flyt kolonner  |  Skift synlighedsstatus for skjulte kolonner  |  Sammenlign områder og kolonner ...
Fremhævede funktioner: Grid fokus   |  Designvisning   |   Stor Formel Bar    Arbejdsbog & Ark Manager   |  Ressourcebibliotek (Autotekst)   |  Datovælger   |  Kombiner regneark   |  Krypter/Dekrypter celler    Send e-mails efter liste   |  Superfilter   |   Specielt filter (filter fed/kursiv/gennemstreget...) ...
Top 15 værktøjssæt12 tekst Værktøjer (tilføje tekst, Fjern tegn, ...)   |   50 + Chart Typer (Gantt kort, ...)   |   40+ Praktisk formler (Beregn alder baseret på fødselsdag, ...)   |   19 Indsættelse Værktøjer (Indsæt QR-kode, Indsæt billede fra sti, ...)   |   12 Konvertering Værktøjer (Tal til ord, Valutaomregning, ...)   |   7 Flet og del Værktøjer (Avancerede kombinere rækker, Opdel celler, ...)   |   ... og mere

Overlad dine Excel-færdigheder med Kutools til Excel, og oplev effektivitet som aldrig før. Kutools til Excel tilbyder over 300 avancerede funktioner for at øge produktiviteten og spare tid.  Klik her for at få den funktion, du har mest brug for...

Beskrivelse


Fanen Office bringer en grænseflade til et kontor med Office, og gør dit arbejde meget lettere

  • Aktiver redigering og læsning af faner i Word, Excel, PowerPoint, Publisher, Access, Visio og Project.
  • Åbn og opret flere dokumenter i nye faner i det samme vindue snarere end i nye vinduer.
  • Øger din produktivitet med 50 % og reducerer hundredvis af museklik for dig hver dag!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
jak ktoś ukrył arkusz jak w opisanym pierwszym sposobie, a nie znamy hasła to jak odkryć arkusz skoro hasło do visual basic jest w ukrytym arkuszu?
This comment was minimized by the moderator on the site
Hello, ciekawa

Sorry, at present, there is no good way for canceling the protect of the hidden sheet if you forget the password.

But, you can apply the Uhide all hidden sheets feature of Kutools for Excel to unhide all the hidden sheets without any password.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-unhide-sheets.png
You can download Kutools for Excel and use it freely for 30 days.
Please have a try. Thank you!
This comment was minimized by the moderator on the site
This is elegant. IF the person opening the spreadsheet does not enable macros (i.e. VBA) what happens? Is the hidden sheet a sitting duck? Or is it quite impossible to find?
This comment was minimized by the moderator on the site
Hi, David,
If you open the workbook without enabling the macro, the hidden sheet is displayed as normal. In this case, I recommend you to apply the first method for solving this job.
Thank you!
This comment was minimized by the moderator on the site
Your code allows users to view the sheet as long as they hold the left mouse button while the mouse pointer is on the tab. Try this to keep sheet hidden until correct password is entered: If response = "123456" Then Application.Sheets(xSheetName).Visible = True Application.Sheets(xSheetName).Select Else Application.Sheets(xSheetName).Visible = False[/b][/b] End If End If Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
I have a question about your password restricted worksheet code. You posted the following code which works....what I am looking for is code that will do this with multiple worksheets and multiple passwords within the same workbook. Is this possible? Private Sub Workbook_SheetActivate(ByVal Sh As Object) 'Update 20140925 Dim xSheetName As String xSheetName = "sheet1" If Application.ActiveSheet.Name = xSheetName Then Application.EnableEvents = False Application.ActiveSheet.Visible = False xTitleId = "KutoolsforExcel" response = Application.InputBox("Password", xTitleId, "", Type:=2) If response = "123456" Then Application.Sheets(xSheetName).Visible = True Application.Sheets(xSheetName).Select End If End If Application.Sheets(xSheetName).Visible = True Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
Found a solution yet?

I am having the same problem
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim aSheetName As String
Dim bSheetName As String
Dim cSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "123" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "456" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "789" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Thanks for the code, just have one question. When you open the sheet you are asked for question, then you enter it and the sheet is visible, but when you jump to next sheet and try to re-open previous sheet, you are asked for the same password again everytime. My question is can you bypass that and make excel ask for password once?
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "1234" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "2345" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "3456" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations