View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Delete check boxes automatically

You added checkboxes from the Forms toolbar.

Don't use that second suggestion. Use the first.

Johan wrote:

Tnx Dave, but it doesn't work yet.

I use the following Macro to add the checkboxes to a selected area:

Sub chckbxmkr()

On Error Resume Next
Dim c As Range, myRange As Range
Set myRange = Selection
For Each c In myRange.Cells
ActiveSheet.CheckBoxes.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.LinkedCell = c.Address
.Characters.Text = ""
.Name = c.Address
End With
c.Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=" & c.Address & "=TRUE"
.FormatConditions(1).Font.ColorIndex = 6 'change for other color when
ticked
.FormatConditions(1).Interior.ColorIndex = 6 'change for other color
when ticked
.Font.ColorIndex = 2 'cell background color = White
End With
Next
myRange.Select
End Sub

But if I run your code I get an error on this:
"TypeOf myCBX.Object Is MSForms.CheckBox"

Can you help out? Tnx again,

Johan


--

Dave Peterson