slamet Harto
09-23-2008, 01:20 AM
Hi there,
I'm trying to create a checkbox by looping in a column. However, I can see the following error message "Object Variable with block variable not set".
Can you help to solve it.
Thanks for everything. Rgds, harto
Here's what I have done, so far:
Sub LoopToCreateChkbox()
Dim i As Integer
Dim c As Range
Range("C2").Select
For i = 1 To Selection.CurrentRegion.Rows.Count - 1
ActiveSheet.CheckBoxes.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.LinkedCell = c.Address
.Characters.Text = ""
.Name = "Check" & c.Address
End With
Next i
ActiveCell.Offset(1, 0).Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & c.Address & "=TRUE"
.FormatConditions(1).Font.ColorIndex = 6
.FormatConditions(1).Interior.ColorIndex = 6
.Font.ColorIndex = 2
End With
End Sub
I'm trying to create a checkbox by looping in a column. However, I can see the following error message "Object Variable with block variable not set".
Can you help to solve it.
Thanks for everything. Rgds, harto
Here's what I have done, so far:
Sub LoopToCreateChkbox()
Dim i As Integer
Dim c As Range
Range("C2").Select
For i = 1 To Selection.CurrentRegion.Rows.Count - 1
ActiveSheet.CheckBoxes.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.LinkedCell = c.Address
.Characters.Text = ""
.Name = "Check" & c.Address
End With
Next i
ActiveCell.Offset(1, 0).Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & c.Address & "=TRUE"
.FormatConditions(1).Font.ColorIndex = 6
.FormatConditions(1).Interior.ColorIndex = 6
.Font.ColorIndex = 2
End With
End Sub