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:
................................
You're not going to believe this. I was just explaining to my wife what
the problem was as I was finishing this post off, and it's all working
and aligned just fine now when I went to show her. I don't know what
exactly happened. I reopened the closed worksheet and it worked just
fine. Maybe I did something before I closed it last time and I sent
myself on a wild goose chase?! Anyway, feel free to read the rest of it
since I typed it out! LOL! I feel stupid now.
................................
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
SteveW wrote:
Missed the post earlier with the VB code
Not sure why you are using VB code - A WinDing character set has a
tick in it.
A little macro
Sub Char_Tick()
'
' Put a Tick into current cell
' Use 251 for a Cross
ActiveCell.Font.Name = "Wingdings"
ActiveCell.FormulaR1C1 = "=CHAR(252)"
End Sub
This then will obviously be a standard cell and won't need any
special aligning
Steve