Ga naar hoofdinhoud

Hoe een werkbladtabblad in Excel te vergrendelen of vast te zetten?

Stel dat u een werkmap heeft die meerdere werkbladen bevat, dan is er een werkblad met de naam Hoofdblad als eerste tabblad in de werkmap. En nu wilt u proberen dit bladtabblad te vergrendelen of vast te zetten om het altijd zichtbaar te maken, zelfs wanneer u over een aantal werkbladen bladert. Er is in feite geen directe manier om het tabblad vast te zetten, maar u kunt een tijdelijke oplossing gebruiken om dit probleem op te lossen.

Vergrendel of zet een specifiek werkbladtabblad vast met VBA-code


pijl blauw rechts bel Vergrendel of zet een specifiek werkbladtabblad vast met VBA-code

In Excel kunnen we de volgende VBA-code toepassen om het specifieke werkblad altijd vóór uw huidige aangeklikte werkbladtabblad te maken, zodat u dit werkblad altijd kunt zien wanneer u over andere bladtabbladen bladert. Ga als volgt te werk:

1. Houd de ALT + F11 toetsen, en het opent de Microsoft Visual Basic for Applications-venster.

2. Kies dan Dit Werkboek van links Projectverkenner dubbelklik erop om het Module, en kopieer en plak vervolgens de volgende VBA-code in de lege module:

VBA-code: bevries of vergrendel een specifiek werkbladtabblad

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Update by Extendoffice
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.ActiveSheet.Index <> Application.Sheets("Main-sheet").Index Then
    Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index)
    Application.Sheets("Main-sheet").Activate
    Sh.Activate
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

doc-freeze-sheet-tabblad-1

3. En sla deze code vervolgens op en sluit deze, wanneer u nu op een van uw werkbladtabbladen klikt, staat dit specifieke werkblad altijd vooraan op uw aangeklikte bladtab, zie schermafbeeldingen:

doc-freeze-sheet-tabblad-2
-1
doc-freeze-sheet-tabblad-3

Note: In de bovenstaande code is het hoofdblad de bladnaam die u wilt bevriezen, u kunt deze naar uw behoefte wijzigen.


Gerelateerde artikelen:

Hoe deelvensters in Excel 2010 te bevriezen?

Hoe kan ik deelvensters bevriezen / vrijgeven op meerdere werkbladen tegelijk toepassen?

Beste Office-productiviteitstools

🤖 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar efficiëntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
chăng đc gi cả
This comment was minimized by the moderator on the site
As Thuyen pointed out 2 years ago, you can't copy data between sheets while this code is active. Furthermore, the code is needlessly complicated. The sheet that you activate is passed to the procedure as the parameter "Sh". This makes the frequent calls to "ActiveSheet" unnecessary, and could cause problems for someone who's trying to modify the code but isn't very experienced.

Here's my versions that corrects those issues, and even shows how to add a 2nd "Main" sheet (similar to what Dzingai posted):
-----------------------------------------------------------------

'These 2 lines aren't necessary if you use the sheets' codenames, which I recommend.
Set shtMain1 = Worksheets("Main-Sheet-1")
Set shtMain2 = Worksheets("Main-Sheet-2")

If Application.CutCopyMode = False Then
If Sh.Index <> shtMain1.Index And Sh.Index <> shtMain2.Index Then
shtMain1.Move before:=Sh
shtMain2.Move before:=Sh
Sh.Activate
End If
End If
This comment was minimized by the moderator on the site
This code worked well. Only problem is...if we close the file & open it again it goes off.
This comment was minimized by the moderator on the site
[quote]This code worked well. Only problem is...if we close the file & open it again it goes off.By Sangs[/quote] Try saving document as Macro-Enabled Workbook. I think it should work well that way.
This comment was minimized by the moderator on the site
Is it possible to create one with multiple arguments? Like instead of just moving the one main sheet to the front of where you are working, is it possible to move three tabs in front of what you are working on?
This comment was minimized by the moderator on the site
Yes, it is possible, you just have to add more arguments to the if clause using the "AND" like this IF Application.ActiveSheet.Index Application.Sheets("Main-sheet").Index AND Application.ActiveSheet.Index Application.Sheets("Other-Main-sheet").Index and so on... Then Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.Sheets("Other-Main-sheet").Index) Application.Sheets("Main-sheet").Activate Application.Sheets("Other-Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index) Application.Sheets("Other-Main-sheet").Activate Sh.Activate This will place the Main-Sheet, then the Other-Main-Sheet in front of your active sheet.
This comment was minimized by the moderator on the site
is this vba my excel sheet not freezeplease give me solution
This comment was minimized by the moderator on the site
Could not get your code to work, but this one did :) Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim sc As Long ' count of sheets Dim NewPos As Long ' index of serlected sheet Application.EnableEvents = False Application.ScreenUpdating = False If ActiveSheet.Index 1 Then sc = Sheets.Count NewPos = ActiveSheet.Index For i = 2 To NewPos - 1 Sheets(2).Move After:=Sheets(sc) Next i Sheets(1).Activate Sheets(2).Activate End If Application.ScreenUpdating = True Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
When I use VBA, I cannot copy data from Main-Sheet to another sheet Please help me fix this bug
This comment was minimized by the moderator on the site
hahaha. so true! did you find a fix for this?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations