ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Ãö©ó UserForm1.Controls.Add "Forms.CommandButton.1" °ÝÃD½Ð±Ð

[µo°Ý] Ãö©ó UserForm1.Controls.Add "Forms.CommandButton.1" °ÝÃD½Ð±Ð

ii = Sheets("sheet2").Range("m1").Value
For ii = 1 To ii
    UserForm1.Controls.Add "Forms.CommandButton.1", "CommandButton" & ii, True
Next
¥H¤W°õ¦æµ²ªG¦p¤U¹Ï


½Ð±Ð¦U¦ì¥ý«ô ¦p¦ó«ö ¦U­Ó CommandButton °õ¦æ¥¨¶°©O?
¬O§_­n¥Î¨ì  ª«¥ó¯S§O¼Ò²Õ  ¦³³Ò¤j¤jÅo   ÁÂÁÂ!!

¦^´_ 1# pinklee
  1. Private Sub UserForm_Initialize()
  2.     Dim fcb As MSForms.CommandButton
  3.     fcbWidth = 30
  4.     fcbNum = 5
  5.     For ii = 1 To fcbNum
  6.         Set fcb = UserForm1.Controls.Add("Forms.CommandButton.1", "CommandButton" & ii, True)
  7.         fcb.Width = fcbWidth
  8.         fcb.Left = (ii - 1) * fcbWidth
  9.         fcb.Caption = "C" & ii
  10.     Next
  11. End Sub
½Æ»s¥N½X
ss

TOP

¥»©«³Ì«á¥Ñ sunnyso ©ó 2013-6-1 00:19 ½s¿è

¦^´_ 1# pinklee
  1. Dim AllBtn() As New Class1

  2. Private Sub UserForm_Initialize()
  3.     Dim fcb As MSForms.CommandButton
  4.     Dim fcbNum As Integer
  5.     fcbWidth = 30
  6.     fcbNum = 5 'Sheets("Á`ªí").Range("A1").Value
  7.     ReDim AllBtn(1 To fcbNum)
  8.     For ii = 1 To fcbNum
  9.         Set fcb = UserForm1.Controls.Add("Forms.CommandButton.1", "CommandButton" & ii, True)
  10.         Set AllBtn(ii).Btn = fcb
  11.         fcb.Width = fcbWidth
  12.         fcb.Left = (ii - 1) * fcbWidth
  13.         fcb.Caption = "C" & ii
  14.     Next
  15. End Sub
½Æ»s¥N½X
ª«¥óÃþ§O¼Ò²Õ
  1. Public WithEvents Btn As MSForms.CommandButton

  2. Private Sub Btn_Click()
  3.     'Dim ctrl As Control
  4.     'With UserForm1
  5.         'your code here
  6.         MsgBox Btn.Caption
  7.     'End With
  8. End Sub
½Æ»s¥N½X
ss

TOP

¦^´_ 3# sunnyso


    ·PÁ±zªº«ü¾É  §Ú¥ý¬ã¨s¤@¤U

TOP

¦^´_ 3# sunnyso


    ·PÁ±z ¤w¸g¥i¥H¨Ï¥Î

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD