By: Shamima Sultana

In reply to Sara.

Hello Sara,

Yes, you can achieve this with a bit of VBA. Excel doesn’t support adding form controls like checkboxes conditionally through formulas, but you can use a simple macro to loop through a range and add checkboxes next to cells that contain text.
Here’s a sample VBA code that adds checkboxes conditionally next to cells only if the adjacent cell contains text:
1. Press Alt + F11 to open the VBA Editor.
2. Insert a new module (Insert > Module).
3. Paste the code and run it (F5) while your desired worksheet is active.

Sub AddConditionalCheckboxes()
Dim ws As Worksheet
Dim rng As Range, cell As Range
Dim lastRow As Long
Set ws = ActiveSheet

' Define the column range (e.g., A2:A100)
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
Set rng = ws.Range("A2:A" & lastRow)

For Each cell In rng
If cell.Value <> "" Then
' Add checkbox in the adjacent cell (Column B)
With ws.CheckBoxes.Add(cell.Offset(0, 1).Left, cell.Offset(0, 1).Top, 15, 15)
.Caption = ""
.LinkedCell = cell.Offset(0, 1).Address
.Display3DShading = True
End With
End If
Next cell
End Sub

Regards
ExcelDemy