asked on
Sub NewCheckbox()
Dim lRow As Long
Dim target As Range
Dim obj As Object
'Adds a Forms toolbar checkbox to the cell
'Checkbox value is linked to that same cell, using a white font color
With Worksheets("Input")
lRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Row 'find first empty row in database
Set target = .Cells(lRow, 1)
With .CheckBoxes.Add(target.Left, target.Top + 1, target.Width, target.Height - 1)
.Caption = "Fakturer"
.LinkedCell = target.Address
.Name = "cb_" & target.Address(False, False) 'Name it like "cb_A11"
.OnAction = "CheckboxClicked"
End With
target.Font.ColorIndex = 2 'White font color for linked cell TRUE/FALSE value
target.Value = False
End With
End Sub
ASKER
Sub NewCheckbox()
Dim lRow As Long
Dim target As Range
Dim obj As Object
'Adds a Forms toolbar checkbox to the cell
'Checkbox value is linked to that same cell, using a white font color
With Worksheets("Input")
For lRow = .ListObjects(1).DataBodyRange.Row To .ListObjects(1).DataBodyRange.Rows.Count + _
.ListObjects(1).DataBodyRange.Row - 1
Set target = .Cells(lRow, 1)
With .CheckBoxes.Add(target.Left, target.Top + 1, target.Width, target.Height - 1)
.Caption = "Fakturer"
.LinkedCell = target.Address
.Name = "cb_" & target.Address(False, False) 'Name it like "cb_A11"
.OnAction = "CheckboxClicked"
End With
target.Font.ColorIndex = 2 'White font color for linked cell TRUE/FALSE value
target.Value = False
Next
End With
End Sub
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY