Gå til hovedindhold

Hvordan bruges knappen til at vise skjulte kolonner i Excel?

Denne artikel viser dig metoder til at oprette og bruge knappen til at vise og skjule kolonner i Excel.

Brug knappen til at vise skjul kolonner med skift-knappen
Brug knappen til at vise skjulte kolonner med Kutools til Excel


Brug knappen til at vise skjul kolonner med skift-knappen

Du kan oprette en vippeknap for at vise skjulte kolonner ved at klikke på den. Gør som følger.

1. klik Udvikler > indsatte > Vippeknap (ActiveX-kontrol). Se skærmbillede:

Bemærk: Hvis du ikke kan se Udvikler fanen på båndet, klik venligst Vis / vis udviklerfanen i Excel at vide, hvordan man aktiverer det.

2. Tegn en vippeknap på regnearket. Højreklik på det, og vælg derefter Vis kode fra højreklikmenuen. Se skærmbillede:

3. I åbnet Microsoft Visual Basic-applikationer vindue, skal du udskifte alt indhold i kodevinduet med nedenstående VBA-kode.

VBA-kode: knap for at vise skjulte kolonner

Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "F:G"
If ToggleButton1.Value Then
    Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
    Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub

Bemærk: “F: G” i koden betyder, at kolonner F: G vises og skjules, mens koden køres. Skift dem til dine behov.

4. Trykke andre + Q taster samtidigt for at lukke Microsoft Visual Basic-applikationer vindue.

5. Sluk for Design Mode med at klikke Udvikler > Design Mode.

Nu når du klikker på skifteknappen, skjules de angivne kolonner straks.

Mens du klikker på den igen, vises kolonnerne.


Brug knappen til at vise skjulte kolonner med Kutools til Excel

Hvis der allerede er kolonner gemt i dit regneark, Kutools til Excel's Skift for at skjule / skjule alle skjulte kolonner hjælpeprogram kan hjælpe dig med hurtigt at vise og skjule dem med et enkelt klik.

Før påføring Kutools til Excel, Bedes download og installer det først.

1. klik Kutools > Navigation.

2. Skift til Kolonneliste ruden, og derefter kan du klikke på Skift for at skjule / skjule alle skjulte kolonner knap for at vise / skjule kolonner i det aktuelle regneark.

  Hvis du vil have en gratis prøveperiode (30 dage) af dette værktøj, klik for at downloade det, og gå derefter til at anvende handlingen i henhold til ovenstående trin.


Brug knappen til at vise skjulte kolonner med Kutools til 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 (17)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Hello, I hope you are well.
If you can help me... I'd appreciate it. I would like to include an image in the button, would it be possible to place it directly in this code?
Rated 4 out of 5
This comment was minimized by the moderator on the site
Hi Eliza,

You can add a picture to a Toggle Button using its "Picture" property. Here's how to do it:
Right click the button and select Properties, in the Properties dialog box, go to the Categoried tab, look for the "Picture" property, click the ellipsis (...) next to the "Picture" property to open the file dialog and then you can select the picture you want.
This comment was minimized by the moderator on the site
Hi, Crystal
It doesn't work perfectly as I wanted, I had already tried... But I managed to do it another way. Thanks for the help! :)
Your content is very educational and helps many people, keep it up.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Olá, espero que você esteja bem.
Se conseguir me ajudar.. agradeço. Gostaria de incluir uma imagem no botão, seria possível colocar diretamente nesse código?
This comment was minimized by the moderator on the site
Hi what is the code to hide rows instead of columns
Thanks
This comment was minimized by the moderator on the site
Hi Andy,
This VBA code can help. Please give it a try. Thank you.
You need to change the row number in the xAddress line to the rows you want to hide.
Private Sub ToggleButton1_Click()
'Updated by Extendoffice 20230915
Dim xAddress As String
xAddress = "5:10"
If ToggleButton1.Value Then
    Application.ActiveSheet.Rows(xAddress).Hidden = True
Else
    Application.ActiveSheet.Rows(xAddress).Hidden = False
End If
End Sub
This comment was minimized by the moderator on the site
Bonjour,

Top cela fonctionne bien !!

Cependant dans mon cas de figure je masque plusieurs groupes de colonnes ( ex : un bouton 1 pour masquer les colonnes D:E et un bouton 2 pour masquer les colonnes I:K). Comment faire pour que je puisse masquer un groupe de colonnes de façon indépendante et que je ne sois pas obligé d'activer le bouton 1 afin de pouvoir activer le bouton 2 ?

Je débute merci d'avance :)
This comment was minimized by the moderator on the site
Great written tutorial, but how do I create this button on a shared Excel sheet?
This comment was minimized by the moderator on the site
Hi Madison Taylor Delgado,
Are your workbooks shared on OneDrive or other applications? I am not able to solve this problem yet. Sorry for that.
This comment was minimized by the moderator on the site
Bom dia!

Eu gostaria de ajuda com um código para Control ActiveX onde eu pudesse selecionar colunas intercaladas.

Obrigado
This comment was minimized by the moderator on the site
I tried the formula on 3 buttons. The problem is they hide and unhide according to the sequenced they are inputted in the code. Is there anyway that I can click any button that will show/hide the columns not in sequence?
This comment was minimized by the moderator on the site
Adding to Ryan's comment, how about hiding a column based on the value of a cell? Basically making the xAdress an IF-function and not a predetermined range of columns.
This comment was minimized by the moderator on the site
Dear Liz,

Thank you for your comment!

VBA code in this tutorial can help you hiding specified columns based on the value of a cell. Please follow the below hyperlink to know more details.
https://www.extendoffice.com/documents/excel/2682-excel-hide-columns-based-on-dropdown-list.html
This comment was minimized by the moderator on the site
Hi there, How would you change it to select a bunch of non-adjacent cells?
This comment was minimized by the moderator on the site
Dear Ryan,

If you need to select a bunch of non-adjacent cells (every selected cell is interval of X cell) as below screenshot shown, please try the Select Interval Rows & Columns utility of Kutools for Excel.

You can also follow this link to know more about this feature. Thank you!
https://www.extendoffice.com/product/kutools-for-excel/excel-select-interval-rows-or-columns.html
This comment was minimized by the moderator on the site
Dear Ryan,

About the bunch of non-adjacent cells you need to select, can you provide a screenshot to show where they locating in your worksheet?
Thank you for your comment.
This comment was minimized by the moderator on the site
This was very helpful, thanks!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations