mercredi 19 juillet 2017

Excel VBA - position of checkbox inside of the cell

I cannot position my checkbox to the right side of the cell.

Macro adds button to specific cell to the left top corner, but when I want to Add also checkbox to the same cell it wont go to the right side, how can I do that ? Apparently the number 50 in the line Set chkbx is used to set the position. But my checkbox only goes to the left when I change it to the negative number. But it wont go to the right. How can I do it ?

Set t = ActiveSheet.Range(Cells(10, NewColumn), Cells(10, NewColumn))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, 0, 0)
With btn
  .OnAction = "Button_clicked"
  .Caption = "X"
  .Width = 15
  .Height = 12
  .Name = "Delete_button_" & x
End With

/HERE IS THE CHECKBOX I WANT TO HAVE IN THE RIGHT UPPER CORNER/

Set chkbx = ActiveSheet.CheckBoxes.Add(t.Left, t.Top, 50, 0)
With chkbx
    .Name = "CheckBox_" & x
    .Caption = ""
End With

enter image description here




Aucun commentaire:

Enregistrer un commentaire