Ga naar hoofdinhoud

Hoe selectievakjes aan meerdere cellen in Excel te koppelen?

Door de selectievakjes aan meerdere relatieve cellen te koppelen, kunt u snel en gemakkelijk enkele berekeningen uitvoeren wanneer u alleen de aangevinkte of niet-aangevinkte cellen moet optellen, tellen of gemiddelde. Maar heb je ooit geprobeerd om de selectievakjes aan meerdere cellen tegelijk in een werkblad te koppelen?

Koppel selectievakjes één voor één aan meerdere cellen met de formule

Koppel selectievakjes aan meerdere cellen tegelijk met VBA-code


pijl blauw rechts bel Koppel selectievakjes één voor één aan meerdere cellen met de formule

Om het selectievakje aan een specifieke cel te koppelen, kunt u in feite een eenvoudige formule toepassen om ze handmatig te koppelen.

1. Nadat u de selectievakjes in uw werkblad heeft ingevoegd, drukt u op om het selectievakje te selecteren Ctrl key en klik vervolgens op het eerste selectievakje dat u aan een andere cel wilt koppelen.

2. Typ vervolgens in de formulebalk het gelijkteken =en klik vervolgens op een cel waaraan u het selectievakje wilt koppelen, B2 bijvoorbeeld, zie screenshot:

doc-link-meerdere-selectievakjes-1

3. En druk vervolgens op Enter toets op het toetsenbord, nu, wanneer u dit selectievakje aanvinkt, wordt de gekoppelde cel weergegeven TRUE, als het niet aangevinkt is, wordt het weergegeven Juist, zie screenshot:

doc-link-meerdere-selectievakjes-2

4. Herhaal de bovenstaande stappen om andere selectievakjes een voor een te koppelen.


pijl blauw rechts bel Koppel selectievakjes aan meerdere cellen tegelijk met VBA-code

Als er honderden en duizenden selectievakjes aan andere cellen moeten worden gekoppeld, zal de eerste methode niet effectief werken, om ze aan meerdere cellen tegelijk te koppelen, kunt u de volgende VBA-code toepassen. Doe alstublieft als volgt:

1. Ga naar je werkblad met de lijst met selectievakjes.

2. Houd de ALT + F11 toetsen om de te openen Microsoft Visual Basic for Applications-venster.

3. Klikken Invoegen > Moduleen plak de volgende code in het Module Venster.

VBA-code: link selectievakjes aan meerdere cellen tegelijk

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. En druk vervolgens op F5 toets om deze code uit te voeren, alle selectievakjes in het actieve werkblad zijn aan de cellen gekoppeld, wanneer u het selectievakje aanvinkt, wordt de relatieve cel weergegeven TRUE, als u een selectievakje uitschakelt, zou de gekoppelde cel moeten worden weergegeven Juist, zie screenshot:

doc-link-meerdere-selectievakjes-3

Note: In de bovenstaande code, i = 2, het nummer 2 is de eerste rij van uw selectievakje en de letter B is de kolomlocatie waar u de selectievakjes naar moet linken. U kunt ze aanpassen aan uw behoefte.


Gerelateerde artikelen:

Hoe selecteer ik alle selectievakjes met een enkel selectievakje in Excel?

Hoe snel meerdere selectievakjes in Excel invoegen?

Hoe snel meerdere selectievakjes in Excel verwijderen?

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 (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