2017-07-19 309 views
0

我無法將我的複選框放在單元格的右側。Excel VBA - 單元格內複選框的位置

宏將按鈕添加到左上角的特定單元格,但是當我想將複選框添加到同一個單元格時,它不會轉到右側,我該怎麼做?顯然,Set Chkbx行中的數字50用於設置位置。但是當我將它改爲負數時,我的複選框只顯示在左邊。但它不會去右邊。我該怎麼做 ?

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 

/這裏是複選框我想在右上角/

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

enter image description here

回答

0

嘗試

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

也沒了,現在它在某處中間,我嘗試改變數字,+和 - 以及更多,但n o好運,無論是在左側還是在完全離開單元格,在下一個 –

+0

在'end with'之前添加語句'Debug.print .Width' - 複選框的寬度是多少(應該是15.75) ? – FunThomas

+0

調試顯示值爲23,25 –

相關問題