Skip to main content

Conas boscaí seiceála a nascadh le ilchealla in Excel?

D’fhéadfadh na boscaí seiceála a nascadh le ilchealla coibhneasta cabhrú leat roinnt ríomhanna a dhéanamh go tapa agus go héasca nuair nach gá duit ach na cealla seiceáilte nó neamhsheiceáilte a shuimiú, a chomhaireamh nó a mheánú. Ach an ndearna tú iarracht riamh na ticbhoscaí a nascadh le ilchealla ag an am céanna i mbileog oibre?

Nasc boscaí seiceála le ilchealla le foirmle ceann ar cheann

Nasc boscaí seiceála le ilchealla ag an am céanna le cód VBA


mboilgeog cheart gorm saighead Nasc boscaí seiceála le ilchealla le foirmle ceann ar cheann

Chun an ticbhosca a nascadh le cill ar leith, i ndáiríre, is féidir leat foirmle shimplí a chur i bhfeidhm chun iad a nascadh de láimh.

1. Tar éis duit na ticbhoscaí a chur isteach i do bhileog oibre, chun an ticbhosca a roghnú, brúigh le do thoil Ctrl eochair agus ansin cliceáil ar an gcéad bhosca seiceála a theastaíonn uait a nascadh le cill eile.

2. Ansin sa bharra foirmle, clóscríobh an comhartha comhionann =, agus ansin cliceáil cill amháin ar mhaith leat an ticbhosca a nascadh leis, B2 mar shampla, féach an scáileán:

doc-link-multip-checkboxes-1

3. Agus ansin brúigh Iontráil eochair ar an méarchlár, anois, nuair a sheiceálfaidh tú an ticbhosca seo, taispeánfaidh an chill nasctha TRUE, má dhéantar é a dhísheiceáil, taispeánfaidh sé FALSE, féach ar an scáileán:

doc-link-multip-checkboxes-2

4. Déan na céimeanna thuas arís chun boscaí seiceála eile a nascadh ceann ar cheann.


mboilgeog cheart gorm saighead Nasc boscaí seiceála le ilchealla ag an am céanna le cód VBA

Má tá na céadta agus na mílte bosca seiceála ann is gá iad a nascadh le cealla eile, ní oibreoidh an chéad mhodh go héifeachtach, chun iad a nascadh le ilchealla ag an am céanna, is féidir leat an cód VBA seo a leanas a chur i bhfeidhm. Déan mar seo le do thoil:

1. Téigh chuig do bhileog oibre le liosta na mboscaí seiceála.

2. Coinnigh síos an ALT + F11 eochracha a oscailt Fuinneog Microsoft Visual Basic for Applications.

3. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: nasc boscaí seiceála le ilchealla ag an am céanna

Sub LinkChecks()
'Update by Extendoffice
Dim xCB
Dim xCChar
i = 2
xCChar = "B"
For Each xCB In ActiveSheet.CheckBoxes
If xCB.Value = 1 Then
    Cells(i, xCChar).Value = True
Else
    Cells(i, xCChar).Value = False
End If
xCB.LinkedCell = Cells(i, xCChar).Address
i = i + 1
Next xCB
End Sub

4. Agus ansin brúigh F5 eochair chun an cód seo a rith, tá gach bosca seiceála sa bhileog oibre gníomhach nasctha leis na cealla, nuair a sheiceálann tú an ticbhosca, taispeánfaidh a chill choibhneasta TRUE, má ghlanann tú bosca seiceála, ba chóir an chill nasctha a thaispeáint FALSE, féach ar an scáileán:

doc-link-multip-checkboxes-3

nótaí: Sa chód thuas, i = 2, an uimhir 2 an tsraith tosaigh de do bhosca seiceála, agus an litir B Is é suíomh an cholúin inar gá duit na boscaí seiceála a nascadh le. Is féidir leat iad a athrú de réir do riachtanas.


Earraí gaolmhara:

Conas gach bosca seiceála a roghnú ag baint úsáide as bosca seiceála amháin in Excel?

Conas ilbhoscaí seiceála a chur isteach go tapa in Excel?

Conas ilbhoscaí in Excel a scriosadh go tapa?

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 (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Will this work when I try to sort Alphabetically? I've found that when I sort from A-Z, the check boxes do not follow the cells they were originally next to. Will your method help? Thank you!
This comment was minimized by the moderator on the site
My problem is: I am creating a to do list with daily habits. I want to be able to make statistics from it using the true and false from checking the box linked to a cell but do not want to individually do it, but when i use the code nothing happens?
This comment was minimized by the moderator on the site
Hello, Gregor,
The VBA code works well in my workbook.
You can upload your file here, so that we can check where the problem is.
Thank you!
This comment was minimized by the moderator on the site
Здравствуйте.
Подскажите. Возможно ли суммирование чисел в ячейках по установке флажка?

https://drive.google.com/file/d/1qmEnngPDdgWTISJETJ44IkxG-MABfqhh/view?usp=sharing[/img][/b][/u][/b

В ячейке F3 скрыто число 2 а в ячейке G3 скрыто число 0,3, можно ли сделать так чтоб при установки галочки в ячейке Q3 вычислялась сумма.
Сумма вычислений только на строку в диапазоне F3-P3
This comment was minimized by the moderator on the site
great thread and it works for me.
BUT, I need to save the TRUE/FALSE data to another sheet. What is the VBA to save it to another sheet other than the active one?
This comment was minimized by the moderator on the site
How about if you have some empty rows in ColumnA (as per your example) in between checkboxes? Using the above code it gets the linked cells wrong if there are empty rows because it does not skip them. Interested to see the solution
This comment was minimized by the moderator on the site
Did u find any solution for this? Same problem
This comment was minimized by the moderator on the site
Sub LinkCheckBoxes()

Dim chk As CheckBox

Dim lCol As Long

lCol = 1 'number of columns to the right for link



For Each chk In ActiveSheet.CheckBoxes

With chk

.LinkedCell = _

.TopLeftCell.Offset(0, lCol).Address

End With

Next chk



End Sub
This comment was minimized by the moderator on the site
Hello! Nice post about the VBA... but what if there are 3 columns that has checkboxes that needs to be linked in three other columns as well? Let's say columns B, C, and D has checkboxes and should be linked to columns H, I, and J respectively.
This comment was minimized by the moderator on the site
Hi, Having same problem - Have you found out how to get around this? Thanks, Paul
This comment was minimized by the moderator on the site
Hey,

Try this:

Sub LinkCheckBoxes()
Dim chk As CheckBox
Dim lCol As Long
lCol = 2 'number of columns to the right for link

For Each chk In ActiveSheet.CheckBoxes
With chk
.LinkedCell = _
.TopLeftCell.Offset(0, lCol).Address
End With
Next chk

End Sub



If you have for example, checkboxes in D,E,F change "Icol" to 1, so it links to G,H and I, respectively.
This comment was minimized by the moderator on the site
Hi, I have the same issue but did not work for me, can you help please.Thanks
This comment was minimized by the moderator on the site
thank you very much
This comment was minimized by the moderator on the site
Can you help me out with this same problem?
This comment was minimized by the moderator on the site
Can I do this and program the boxes to say something other than true and false?
This comment was minimized by the moderator on the site
Hi, In your VBA code: link checkboxes to multiple cells at once, the code is set up to link the cell below it. How is the code if I want to link the cell to the left of the first one? Thanks!
This comment was minimized by the moderator on the site
i have more than 40000 cell which have checkbox. when i use this code, it takes more than 5 second to process, i define different macros for different cells but i have still the problem, what can i do?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations