checkbox

R

ranswert

I have the following code:

Sub addcheckbox()
Dim a As String
Dim costid As String
Dim cboxname As Integer
Dim cell As Range
Dim chk As Excel.CheckBox
Set cell = ActiveCell
Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
costid = id
'MsgBox ("costid =" & costid)
chk.Height = cell.Height - 1.5
cboxname = ActiveCell.EntireRow.Cells(13)
chk.Characters.Text = none
chk.name = "Checkbox" & costid & cboxname
chk.LinkedCell = ActiveCell.EntireRow.Cells(14).Address
ActiveCell.Select

End Sub

Which had been working fine. I'm not sure what I did, but now the checkbox
is added 3 rows up instead of centering it in the selected cell.

Can you tell me what to do to fix this?
Thanks
 
R

ranswert

The checkbox is put in the wrong spot when I have the zoom at less than
100%. It works fine when the zoom is at 100%. Can someone explain to me why
this happens, and how I can fix it?
Thanks
 
D

Dave Peterson

Keep track of the zoom
Change the zoom to 100%
do the work
change the zoom back to what it was before

If you turn application.screenupdating off at the beginning, it shouldn't be
noticeable. (And turn application.screenupdating back on at the end.)
 
R

ranswert

Is there a way to write a code that will set a variable to the current zoom
setting, so I can reset it after the checkbox is added? or Can I rewrite the
addcheckbox to center it in a cell that wouldn't make a difference on the
zoom?
Thanks
 
D

Dave Peterson

You could screw around trying to tweak your code for perfect placement, but I
bet you'll find it easier to change the zoom.

Record a macro when you change the zoom and you'll have the syntax.
 
R

ranswert

Thanks I'll try that

Dave Peterson said:
You could screw around trying to tweak your code for perfect placement, but I
bet you'll find it easier to change the zoom.

Record a macro when you change the zoom and you'll have the syntax.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

check boxes 7
checkbox 2
centering checkboxes vertical in cell 3
checkbox centered in cell 4
intersect 12
I need help again 4
Events for CheckBox inside Excel using ExcelAddIn project 0
check box Error 2

Top