Excel ActiveX Checkboxes
SoftTech Tutorials
Excel ActiveX Checkboxes
https://softtechtutorials.com/microsoft-office/excel/excel-activex-checkboxes/
Introduction 0:00 developer tab 0:36 Insert Checkboxes 1:13 Center Checkboxes 2:54 Checkbox Analysis 3:37
Below you can find the VBA codes that we used in this Excel ActiveX checkboxes tutorial:
Insert Checkboxes Code:
Sub insertCheckboxes()
Dim cell As Range
Dim checkboxCells As Range
Dim objOLE As OLEObject
Set checkboxCells = Application.Selection
Set checkboxCells = Application.InputBox("Range", "Analysistabs", checkboxCells.Address, Type:=8)
For Each cell In checkboxCells
Set objOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1")
With objOLE
.Left = cell.Left
.Top = cell.Top + 1
.Width = 10
.Height = cell.Height - 3
.LinkedCell = cell.Worksheet.Name & "!" & cell.Address
.Object.Value = False
.Object.Caption = ""
End With
Next
centerCheckboxes
End Sub
Sub centerCheckboxes() Dim position As Range Dim checkBox As OLEObject
For Each checkBox In ActiveSheet.OLEObjects
If TypeName(checkBox.Object) = "CheckBox" Then
Set position = checkBox.TopLeftCell
checkBox.Left = position.Left + (position.Width - checkBox.Width) / 2
checkBox.Top = position.Top + (position.Height - checkBox.Height) / 2 + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Sub checkboxAnalysis() Dim i As Integer Dim r1 As Range Dim r2 As Range Dim startDate As Range Dim ruleDate As Range
For i = 2 To 51
Set r1 = Range("C" & i & ":E" & i)
Set r2 = Range("F" & i)
Set startDate = Range("B" & i)
Set ruleDate = Range("H3")
res = Application.And(r1)
If res = False And startDate < ruleDate Then
r2.Value = "NOT OK"
r2.Interior.Color = RGB(255, 199, 206)
r2.Font.Color = RGB(156, 0, 6)
Else
r2.Value = "OK"
r2.Interior.Color = RGB(255, 255, 255)
r2.Font.Color = RGB(0, 0, 0)
End If
Next i
End Sub
This concludes our tutorial on how to create multiple checkboxes in Excel with ActiveX. ... https://www.youtube.com/watch?v=mHhx5x1_M94
2021-12-29
0.0 LBC
Copyrighted (contact publisher)
31943754 Bytes