返回列表 上一主題 發帖

excel 產生多個核取方塊.

  1. Sub test()
  2.     For Each c In ActiveSheet.Cells.SpecialCells(2)
  3.         Set b = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
  4.                                            Left:=c(1, 2).Left, Top:=c.Top, Width:=c.Width, Height:=c.Height)
  5.         b.Object.Caption = c.Value
  6.     Next
  7. End Sub
複製代碼

TOP

若你想用LinkedCell屬性計算,那就是表單工具的核取方塊了,可改成這樣:(例如LinkedCell放在m欄)
  1. Sub test()
  2.     For Each c In ActiveSheet.Cells.SpecialCells(2)
  3.         Set b = ActiveSheet.CheckBoxes.Add(c(1, 2).Left, c.Top, c.Width, c.Height)
  4.         b.Characters.Text = c.Value
  5.         i = i + 1
  6.         b.LinkedCell = Cells(i, 13).Address
  7.     Next
  8. End Sub
複製代碼

TOP

回復 9# oobird


    結果如圖:

TOP

        靜思自在 : 一句溫暖的話,就像往別人身上灑香水,自己會沾到兩三滴。
返回列表 上一主題