Checkbox Series to create DataBar Sets

NinaE_11

Board Regular
Joined
Aug 18, 2020
Messages
67
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I'm attempting to create a list with four columns of checkboxes, adding up the "TRUE" in each row, left to right, to formulate a databar visual at the end of each row.

I've got a very long list, so manually linking each contiguous manually, for four columns, could be quite time consuming. I've found some VBA language that will link contiguous cells for each row, but it will only work when there is only one column of checkboxes. i.e. - the below example would work if checkboxes were in Column A, and I wanted a "TRUE" in Column B. What I can't figure out is how to move these same details for checkboxes in Column C and a second TRUE/FALSE outcome in Column D.

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

Any insights would be much appreciated! Thank you for taking the time to help!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If you have your worksheet with all the checkboxes set up, then add the code below to a module and run it once.

If you still need to set up your checkboxes:
  1. Add a Formcontrol checkbox to the first cell. Ensure the the checkbox is completely in one cell.
  2. Select this cell and the cells below it which need to get checkboxes.
  3. Press Ctrl-D
  4. Now select this range and the three columns to the right
  5. Press Ctrl-D

Now you have your four columns of checkboxes.

Run the code below once.

Once you have run the code, click a checkbox. You will see 'TRUE' behind the checkbox. If you click it again, it says 'FALSE'.
In the add up column, put the formula to sum up the values of the four cells to the left (for instance =SUM(B3:E3))
Copy the formula down.

Now this column gives the sum of the checked boxes in each row.

Next, for appearances, select all the cells with the checkboxes and set the font colour to the background colour, so the user does not see the TRUE or FALSE.

That's it.

If you add more checkbox rows later, just rerun the macro.

VBA Code:
Option Explicit

Sub LinkCheckBx()
'Links each checkbox to the cell in which it sits
    Dim cbxCB As Object
   
    For Each cbxCB In ActiveSheet.CheckBoxes
        cbxCB.LinkedCell = cbxCB.TopLeftCell.Address
    Next cbxCB
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top