How to Convert True False to Checkbox in Excel?


Sometimes when we have True or False values in Excel, you would have needed to change them to checkboxes for better and accurate analysis. We can solve this task using the VBA application, as it cannot be completed directly in Excel. Read this tutorial to learn how you can convert True to False values to checkboxes in Excel. In other words, the checkbox will be checked if the value is True, and the box will be unchecked if the value is False.

Converting True False to Checkbox in Excel

Here, we will first create a VBA module and then run it to complete our task. Let us look at a simple procedure for converting true to false for checkboxes in Excel using the vba application.

Step 1

Let us consider an Excel sheet where the data in the sheet is similar to the data shown in the below image.

Now right-click on the sheet name and select view code to open the VBA application, then click on insert and select module.

Right click > View code > Insert > Module

Step 2

Type the following program code in the textbox, as shown in the image below −

Program

Sub ConvertTrueFalseToCheckbox()
'Updated By Nirmal
Dim xCB As CheckBox
Dim xRg, xCell As Range
Application.ScreenUpdating = False
On Error Resume Next
Set xRg = Selection
For Each xCB In ActiveSheet.CheckBoxes
xCB.Delete
Next
For Each xCell In xRg
If (UCase(xCell.Value) = "TRUE") Or (UCase(xCell.Value) = "FALSE") Then
Set xCB = ActiveSheet.CheckBoxes.Add(xCell.Left, xCell.Top, cDblCheckboxWidth, xCell.Height)
xCB.Value = xCell.Value
xCB.LinkedCell = xCell.Address
xCB.Text = ""
End If
Next
Application.ScreenUpdating = True
End Sub

Step 3

Then save the sheet as a macro-enabled workbook. Now return to the Excel sheet and select the cells where the true or false values are present, then click F5 in the VBA application to complete our process, and our result will appear similar to the image given below.

Save > Select values > F5

Conclusion

In this tutorial, we used a simple example to demonstrate how you can convert true to false in a checkbox in Excel.

Updated on: 06-Mar-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements