Re: Deleting Checkbox Object in Cell
- From: "AndrewSiffert" <AndrewSiffert@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Jan 2006 10:11:02 -0800
Hello Again, I am new with VBA and I apricate anyone who offers help.
Lets first explain what I am trying to do:
Set up Excel:
In excel sheet1 create four check boxes place them in "E10", "E11",
"E12", "E13". These check boxes have no text, are in 3D and link to "G10",
"G11","G12", "G13" and check the box to make these cells read false.
The problem:
On row 12 incert a row
The problem is when I do this the link moves too the checked cell, but the
check box does not move down with that row. So I want to move the check box
down to the row with the linked cell. So, the Checkbox in "E12" needs to be
moved to "E13".
What can I write to either move this checkbox down a row.
What I tired is to create a new check box knowing wheather it is true or
false and than delete the old one in "E12". But I can't seem to get that to
work.
Current Code
Sub Trial1()
'Create Checkbox
Range("E13").Select
Dim A As String
A = Range("G13")
If A = False Then
Dim c As Range, myRange As Range
Set myRange = Selection
For Each c In myRange.Cells
Active***.CheckBoxes.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.Value = xlOff
.LinkedCell = "g13"
.Display3DShading = True
.Characters.Text = ""
.Name = c.Address
End With
c.Select
Next
End If
'Delete old checkbox
''''Sample Code'''
Dim Cbox As CheckBox
Dim Rng As Range
Set Rng = Range("E12") '<<==== CHANGE
For Each Cbox In Active***.CheckBoxes
If Not Intersect(Cbox.TopLeftCell, Rng) Is Nothing Then
Cbox.Delete
End If
Next Cbox
End sub
"Norman Jones" wrote:
> Hi Andrew,
>
> More flexible would be:
>
> '=============>>
> Sub TestB()
> Dim Cbox As CheckBox
> Dim Rng As Range
>
> Set Rng = Range("A8, C8") '<<==== CHANGE
>
> For Each Cbox In Active***.CheckBoxes
> If Not Intersect(Cbox.TopLeftCell, Rng) Is Nothing Then
> Cbox.Delete
> End If
> Next Cbox
>
> End Sub
> '<<=============
>
> ---
> Regards,
> Norman
>
>
> "AndrewSiffert" <AndrewSiffert@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:7D679DA8-CBBF-4FC9-B5A1-199817E190A5@xxxxxxxxxxxxxxxx
> > Hello,
> > I have not problem creating a checkbox with in a cell. However when it
> > come
> > time to delete the checkbox I can't seem to select the object. Note, the
> > *** has several checkboxes and deleting them by name will not work. I
> > need
> > to reference a cell to delete the checkbox.
> >
> > Active***.CheckBoxes.Delete
> >
> > This works great for all cells but how about if I just want to delete one
> > checkbox in an selected cell.
> >
> > Thanks,
> > Andy
>
>
>
.
- Follow-Ups:
- Re: Deleting Checkbox Object in Cell
- From: Mark Lincoln
- Re: Deleting Checkbox Object in Cell
- References:
- Re: Deleting Checkbox Object in Cell
- From: Norman Jones
- Re: Deleting Checkbox Object in Cell
- Prev by Date: RE: Simple Report is such a pain!
- Next by Date: Command Button question
- Previous by thread: Re: Deleting Checkbox Object in Cell
- Next by thread: Re: Deleting Checkbox Object in Cell
- Index(es):