Skip to main content

Conas bosca seiceála a úsáid chun sraitheanna nó colúin in Excel a cheilt / a cheilt?

Má ghlactar leis go gcaithfidh tú bosca seiceála a úsáid chun sraitheanna nó colúin áirithe a cheilt nó a cheilt. Mar shampla, nuair a dhéantar seiceáil ar an mbosca seiceála um Rialú Gníomhach X, taispeántar na sraitheanna nó na colúin áirithe, ar shlí eile, beidh siad i bhfolach. Taispeánann an t-alt seo duit an modh ar conas bosca seiceála a úsáid chun sraitheanna nó colúin in Excel a cheilt / a cheilt le sonraí.

Úsáid bosca seiceála chun sraitheanna nó colúin le cód VBA a cheilt / a cheilt


Úsáid bosca seiceála chun sraitheanna nó colúin le cód VBA a cheilt / a cheilt

Is féidir leis an gcód VBA seo a leanas cabhrú leat sraitheanna nó colúin áirithe a cheilt / a chur i bhfolach le ticbhosca.

1. Tar éis duit bosca seiceála um Rialú Gníomhach X a chur isteach sa bhileog oibre, cliceáil ar dheis ar an mbosca seiceála agus ansin roghnaigh Féach an cód ón roghchlár cliceáil ar dheis. Féach an pictiúr:

2. Sa Microsoft Visual Basic d’Fheidhmchláir an cód VBA seo a leanas a fhuinneog, a chóipeáil agus a ghreamú isteach i bhfuinneog an Chóid.

Cód VBA: Úsáid bosca seiceála chun sraitheanna nó colúin a cheilt / a cheilt

Private Sub CheckBox1_Click()
    [C:D].EntireColumn.Hidden = Not CheckBox1
End Sub

nótaí:

1. Sa chód VBA, [C: D]. EntireColumn ciallaíonn sé go mbeidh an colún C agus D i bhfolach nó gan cur i bhfolach tríd an mbosca seiceála comhfhreagrach a sheiceáil nó a dhísheiceáil.

2. Chun sraitheanna áirithe mar shraith 6: 9 a cheilt nó a thaispeáint, athraigh an [C: D]. EntireColumn chun [6: 9]. EntireRow sa chód VBA.

3. Brúigh an Eile + Q eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

4. Anois déan an Mód Dearaidh faoi ​​na Forbróir cluaisín mar atá thíos an pictiúr a thaispeántar:

As seo amach, nuair a dhéantar seiceáil ar an mbosca seiceála, taispeántar na sraitheanna nó na colúin shonraithe. Nuair a dhéantar é a dhísheiceáil, cuirtear na sraitheanna nó na colúin shonraithe i bhfolach.


Earraí gaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (26)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bei mir werden die Zellen nicht ausgeblendet, wenn das Kontrollkästchen wieder in aktiv ist.

Mein Ziel ist es mit dem aktiveren des Kontrollkästchen die Zeile 7 einzublenden und wenn ich den Haken wieder entferne sollte Zeile 47 wieder ausgeblendet sein.
Hilfe....
This comment was minimized by the moderator on the site
Hi Rose,
The following VBA code can help.
Private Sub CheckBox1_Click()
[47:47].EntireRow.Hidden = Not CheckBox1
End Sub
This comment was minimized by the moderator on the site
E para ocultar colunas não sequências?
Exemplo: A e C

Esta situação seria aplicado de que forma para A e C ?

"Sub CheckBox1_Click privada ()
[C:D].EntireColumn.Hidden = Não CheckBox1
End Sub"
This comment was minimized by the moderator on the site
Hi,
The following VBA code can do you a favor. Please give it a try.
Private Sub CheckBox1_Click()
'Updated by Extendoffice 20220810
    [C:C, A:A].EntireColumn.Hidden = Not CheckBox1
End Sub
This comment was minimized by the moderator on the site
Bom dia!
Espero que todos estejam bem!

Tenho uma situação onde preciso ocultar / reexibir a coluna utilizando o Control ActiveX quando solecionado o item.

Exemplo: Tenho coluna com os nomes: Planejado, Realizado, Análise Vertical, Análise Vertical, Variação (R$) e Variação (%), no entanto, que poder selecionar individual as colunas intercalando se necessário. Selecionar somente a coluna Realizado e Variação, mesmo não estando na sequencia.

Desde já agradeço,
Welington
This comment was minimized by the moderator on the site
Hi,
Sorry I don't understand what you mean. Would you mind providing a screenshot of your data?
You may need to attach a screenshot or a sample file to describe the problem you encountered more clearly.
This comment was minimized by the moderator on the site
Esse código oculta, mas não executa a reexibição quando desmarcar.

Alguém pode complementar por favor? Preciso de um código para ocultar e reexibir colunas indicadas.

Private Sub CheckBox1_Click()
[C:D].EntireColumn.Hidden = Not CheckBox1
End Sub

Obrigado
This comment was minimized by the moderator on the site
Hi Welington Mesquita,
This VBA code can acheive:
When the checkbox1 is checked, the column C:D are displayed;
When it is unchecked, the column C:D are hidden.
The code works well in my case. Which Excel version are you using?
This comment was minimized by the moderator on the site
What if i wanted to use 3 different checkboxes and wanted them to each toggle hiding different groups of rows? I have tried and looked all over. When I try to modify this code the checkboxes seem to interfere with each other.
This comment was minimized by the moderator on the site
What if i wanted to use 3 different checkboxes and wanted them to each toggle hiding different groups of rows? I have tried and looked all over. When I try to modify this code the checkboxes seem to interfere with each other.
This comment was minimized by the moderator on the site
Very useful, but how can I use it to hide just a part of the spreadsheet? I mean for example cells B2:B11, how to combine those two functions? Thanks.
This comment was minimized by the moderator on the site
It worked, but then when I saved the file, and reopen it doesn't work. I tried saving it as a Macro excel sheet and as a regular workbook. What have I done wrong? I want to give it to someone else to use and don't want them to be confused.
This comment was minimized by the moderator on the site
Hi angela,After adding the code into workbook, please click File > Save as, choose where to save the file, in the Save As dialog box, choose Excel Macro-Enabled Workbook (*.xlsm) from the Save as type drop-down, and finally click Save. Then send this Excel Macro-Enabled workbook to others.
This comment was minimized by the moderator on the site
I was try to unhide the first three role but it was not work.How can I do it ,I know it the person who send me that file wanna know my skill I can solve it or not.
This comment was minimized by the moderator on the site
Hi May,
Sorry I didn't get your point.
This comment was minimized by the moderator on the site
Hello,

Is there a way to hide only one row. If I put 6:9 all rows are hidden, but if I only put 6, it comes out as error. Would appreciate your help, thank you!
This comment was minimized by the moderator on the site
Hi,
Please change the second line in the code to:
[6:6].EntireRow.Hidden = Not CheckBox1.
Thank you for your comment.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations