Problem vertically aligning multiple rows with tickboxes addedusing VB.
OK, once again, thanks for the help. Luckily this is not a majorly
urgent project so I'll keep playing around with it for while and see
what I can achieve.
--
Westie
SteveW wrote:
Ok, see the code - I guessed as much that you were using some object.
Only thing I can think of is when creating the object hold the ALT key
down, this will *snap* the object to the top left of the cell.
The other thing is to make sure the object has the *Move and Size with
cell* attribute
check properties
Steve
On Wed, 26 Jul 2006 10:52:09 +0100, Westie
wrote:
Thanks for replying, Steve.
I didn't post the code originally. I was intending to keep my post
short, but here it is:
Option Explicit
Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range
With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("H7:H500").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Offset(0, 4).Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
End With
End With
Next myCell
End With
End Sub
You can see that I'm adding the tickbox from the forms toolbar - it
can be actively ticked or unticked. What do you call it? An object?
The control is linked to a target cell. That triggers my conditional
formatting colour change depending on the TRUE or FALSE result from
the checkbox. It's not the wingding font checkbox character that I'm
using.
If you throw this macro into a sheet and run it, you'll see my problem.
It seems that "objects" float above the worksheet and it's tricky to
get them precisely aligned to cells - particularly when you use code
to insert 500 of them.
Unless the row heights are set to exactly whatever the vertical
spacing between the checkboxes is, they incrementally get out of
alignment with the rows. I could probably get away with this if I
could match the row height to the height between checkboxes - but I
can't get it right. At least not for 500 of the suckers. I've
played around with different row heights but they all seem to go out
of alignment at some point regardless of what I do. I need a way to
keep the rows AND the checkboxes aligned.
--
Westie
|