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

[µo°Ý] ½Ð±Ð Ãö©ó µ{¦¡¶}ÀY ªº¬ÛÃöºÃ´b(©Ó±µ CheckBox ®Ö¿ï°ÝÃD)

Ãö©óCheckbox®Ö¿ï§PÂ_

¤w³] 10 * 10 ­Ó Checkbox ±±¨î¶µ
·Q½Ð°Ý  ¦p¦óÀH¾÷®Ö¿ï®É ¦bLabel1.Caption  ¥X²{¸Ó±±¨î¶µ¤§Caption ¤º®e¡C
  1. Private Sub CommandButton1_Click()
  2.     Dim mycheckbox1 As MSForms.CheckBox
  3.     For kk = 1 To 100
  4.         Cells(kk, 1) = "¤ý" & kk
  5.     Next kk
  6.          Columns("c:c").Clear
  7.           Columns("c:c").Select
  8.         Selection.ColumnWidth = 15
  9.    
  10.         For sjy = 1 To 450 Step 45

  11.             For sja = 1 To 900 Step 90
  12.                 Set mycheckbox1 = UserForm1.Frame1.Controls.Add("forms.checkbox.1")
  13.                 With mycheckbox1
  14.                     .Left = 10 + sja
  15.                     .Top = 10 + sjy
  16.                     .Width = 70
  17.                     .Height = 20
  18.                     .TextAlign = fmTextAlignCenter
  19.                     .BackColor = &HFFFFC0
  20.                     .Caption = .Name
  21.                 End With
  22.             Next
  23.         Next
  24.     Dim ct As Control

  25.     r = 1
  26.     For Each ct In Controls
  27.     If TypeName(ct.Object) = "ICheckboxControl" Then ct.Caption = Cells(r, 1): Cells(r, 2) = ct.Name
  28.         Cells(r, 3) = ct.Name: r = r + 1
  29.     Next
  30.      aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count
  31.     For hh = 1 To aois
  32.         For kh = 1 To aois
  33.             If Cells(hh, 3) <> "" Then
  34.                 If Mid(Cells(hh, 3), 1, 8) <> "CheckBox" Then
  35.                     Range("c" & hh).Select
  36.                     Selection.Delete Shift:=xlUp
  37.                
  38.                 End If
  39.             End If
  40.         Next
  41.     Next
  42.         
  43.    
  44.     Cells(1, 3).Select
  45. End Sub
½Æ»s¥N½X
¦Û³Ðcheckbox.rar (19.46 KB)

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-10-18 09:15 ½s¿è

¦^´_ 1# mark15jill
¨Ï¥Îª«¥óÃþ§O ¸Õ¸Õ¬Ý
  1. Dim TheCheck() As New Class1  '°ÊºA°}¦C «Å§i¬°·sªºClass1ª«¥óÃþ§Oª«¥ó
  2. Private Sub CommandButton1_Click()
  3.     Dim mycheckbox1 As MSForms.CheckBox
  4.     Dim Sh As Worksheet
  5.      Set Sh = ActiveSheet   
  6.     Sh.Columns("c:c").Clear
  7.     Sh.Columns("c:c").ColumnWidth = 15
  8.     kk = 1
  9.     For sjy = 1 To 450 Step 45
  10.         For sja = 1 To 900 Step 90
  11.             With Frame1.Controls.Add("forms.checkbox.1")
  12.                 Sh.Cells(kk, 1) = "¤ý" & kk
  13.                 Sh.Cells(kk, 3) = .Name
  14.                 .Left = 10 + sja
  15.                 .Top = 10 + sjy
  16.                 .Width = 70
  17.                 .Height = 20
  18.                 .TextAlign = fmTextAlignCenter
  19.                 .BackColor = &HFFFFC0
  20.                 .Caption = Sh.Cells(kk, 1)
  21.                 ReDim Preserve TheCheck(0 To kk - 1)              '­«·s°t¸m °ÊºA°}¦C
  22.                 Set TheCheck(kk - 1).xlCheckbox = Controls(.Name)
  23.                 '°ÊºA°}¦Cªº¤¸¯À «ü©w¨ìª«¥ó¼Ò²Õ¤ºªºª«¥ó
  24.             End With
  25.             kk = kk + 1
  26.         Next
  27.     Next
  28. End Sub
½Æ»s¥N½X
  1. 'VBA´¡¤J ª«¥óÃþ§O¼Ò²Õ ¦Û°Ê©R¦W¬°Class1 ªºµ{¦¡½X
  2. Option Explicit
  3. Public WithEvents xlCheckbox As MSForms.CheckBox
  4. Private Sub xlcheckbox_Click()
  5.     If xlCheckbox = True Then UserForm1.Label1.Caption = xlCheckbox.Caption
  6. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# GBKEE

¤j¤j ÁÂÁ±zªº¸Ñµª¡C
¦ý¥X²{  ReDim Preserve TheCheck(0 To         Åܼƥ¼©w¸q

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¦^´_ 3# mark15jill
§AªþÀÉ¼Ò²Õ ¨S¥[¤W  Option Explicit  ©Ò¥H§Ú´ú¸Õ®É¬O¨S°ÝÃD
¨Ì§Aªº¯à¤O,¬O¥i¥H¸ÕµÛ­×§ïªº
2#
  1. Private Sub CommandButton1_Click()
  2.     Dim mycheckbox1 As MSForms.CheckBox
  3.     Dim Sh As Worksheet
  4.     Set Sh = ActiveSheet ' **¤Ö¤F³oµ{¦¡½X½Ð¥[¤J **
½Æ»s¥N½X

TOP

¦^´_ 4# GBKEE

©êºp Åý¤j¤j±z¨£¯º¤F~
¦]³Ìªñ  VB2010 ©M VBA ¦P®É¥Î¨ì
¦³¨Ç»yªk »y¦ê ¾É­P±`±`·|²V¶Ã
¦p ¦P¤@¨Æ¥ó ¨âÃ䪺»yªk¥i¯à´N¦³®t²§
¦³¸ÕµÛ­×¥¿  ¦ý¶]¥X¨Óªº¦¨ªG¤£ºÉ²z·Q

¦A¦¸·PÁ¤j¤jªº­@¤ß¸Ñ»¡

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

RE: Ãö©óCheckbox®Ö¿ï§PÂ_ [¤w¸Ñ¨M]

·PÁ GBKEE  ªº«ü±Ð
¦³§ä¨ì¤èªk¥h§P§O..
  1. Private Sub CommandButton1_Click()
  2.     Dim mycheckbox1 As MSForms.CheckBox
  3.           Columns("a:c").Clear
  4.           Columns("a:c").Select
  5.     For kk = 1 To 100

  6.         Cells(kk, 1) = "¤ý" & kk
  7.          
  8.     Next kk

  9.      aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count

  10.         Selection.ColumnWidth = 15

  11.    
  12.         For sjy = 1 To 450 Step 45


  13.             For sja = 1 To 900 Step 90

  14.                 Set mycheckbox1 = UserForm1.Frame1.Controls.Add("forms.checkbox.1")

  15.                 With mycheckbox1

  16.                     .Left = 10 + sja

  17.                     .Top = 10 + sjy

  18.                     .Width = 70

  19.                     .Height = 20

  20.                     .TextAlign = fmTextAlignCenter

  21.                     .BackColor = &HFFFFC0

  22.                     .Caption = .Name

  23.                 End With

  24.             Next

  25.         Next

  26.     Dim ct As Control

  27.     r = 1

  28.     For Each ct In Controls

  29.     If TypeName(ct.Object) = "ICheckboxControl" Then ct.Caption = Cells(r, 1): Cells(r, 2) = ct.Name

  30.         Cells(r, 3) = ct.Name: r = r + 1

  31.     Next
  32.       aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count
  33.     For hh = 1 To aois

  34.         For kh = 1 To aois

  35.             If Cells(hh, 3) <> "" Then

  36.                 If Mid(Cells(hh, 3), 1, 8) <> "CheckBox" Then

  37.                     Range("c" & hh).Select

  38.                     Selection.Delete Shift:=xlUp

  39.                
  40.                 End If

  41.             End If

  42.         Next

  43.     Next
  44.      
  45.     Cells(1, 3).Select


  46. End Sub
½Æ»s¥N½X

Private Sub CommandButton2_Click()
     Dim mycheckbox1 As MSForms.CheckBox
     aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count
     For gosj = 1 To aois
        With Controls("Checkbox" & gosj)
            If .Value = True Then
                Label1.Caption = "²{¦b®Ö¿ï¡G" & .Name
            
            End If
        End With
     Next
End Sub

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

[µo°Ý] ½Ð±Ð Ãö©ó µ{¦¡¶}ÀY ªº¬ÛÃöºÃ´b(©Ó±µ CheckBox ®Ö¿ï°ÝÃD)

·Q½Ð°Ý
¤@¯ë¦Ó¨¥
Private Sub UserForm_Initialize()
End Sub
¬° ªì©lª¬ºAªº®É­Ôªºª¬ºA~
©Î

Private Sub CommandButton1_Click()
End Sub

¦ý¦pªG¤µ¤Ñ¬O·Q¥H
Controls("Checkbox" & gosj) ¬°½d³ò
¥Hªí³æ¦Û°Ê§PÂ_¦Ó¤£¥Î CommandButton ¼Ò¦¡¤U

¸Ó«ç±±¨î¤°»ò¤ñ¸û¾A¦X??
µ{¦¡¦p¤U

'¥Dµ{¦¡°Ï¶ô
  1. Private Sub CommandButton1_Click()


  2.     Dim mycheckbox1 As MSForms.CheckBox
  3.           Columns("a:c").Clear
  4.           Columns("a:c").Select
  5.     For kk = 1 To 100

  6.         Cells(kk, 1) = "¤ý" & kk
  7.          
  8.     Next kk

  9.      aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count

  10.         Selection.ColumnWidth = 15

  11.    
  12.         For sjy = 1 To 450 Step 45


  13.             For sja = 1 To 900 Step 90

  14.                 Set mycheckbox1 = UserForm1.Frame1.Controls.Add("forms.checkbox.1")

  15.                 With mycheckbox1

  16.                     .Left = 10 + sja

  17.                     .Top = 10 + sjy

  18.                     .Width = 70

  19.                     .Height = 20

  20.                     .TextAlign = fmTextAlignCenter

  21.                     .BackColor = &HFFFFC0

  22.                     .Caption = .Name

  23.                 End With

  24.             Next

  25.         Next

  26.     Dim ct As Control

  27.     r = 1

  28.     For Each ct In Controls

  29.     If TypeName(ct.Object) = "ICheckboxControl" Then ct.Caption = Cells(r, 1): Cells(r, 2) = ct.Name

  30.         Cells(r, 3) = ct.Name: r = r + 1

  31.     Next
  32.       aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count
  33.     For hh = 1 To aois

  34.         For kh = 1 To aois

  35.             If Cells(hh, 3) <> "" Then

  36.                 If Mid(Cells(hh, 3), 1, 8) <> "CheckBox" Then

  37.                     Range("c" & hh).Select

  38.                     Selection.Delete Shift:=xlUp

  39.                
  40.                 End If

  41.             End If

  42.         Next

  43.     Next
  44.      
  45.     Cells(1, 3).Select

  46. End Sub
½Æ»s¥N½X
'»Ý§PÂ_°Ï¶ô
  1. Private Sub CommandButton2_Click()
  2.      Dim mycheckbox1 As MSForms.CheckBox
  3.      aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count
  4.      For gosj = 1 To aois
  5.         With Controls("Checkbox" & gosj)
  6.             If .Value = True Then
  7.                 Label1.Caption = "²{¦b®Ö¿ï¡G" & .Name
  8.             End If
  9.         End With
  10.      Next

  11. End Sub
½Æ»s¥N½X
¦³¸ÕÅç¹L

Private Sub UserForm_Activate()

End Sub

¦¹¤è¦¡ ¦ýµL¤Ï¬M

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

¦^´_ 7# mark15jill
¨SªþÀÉ,¥u¯à²q²q¬Ý
¥Dµ{¦¡°Ï¶ô   ¬OUserForm¤¤  
Private Sub CommandButton1_Click()   §ï¦¨  
Private Sub UserForm_Activate()  »P Private Sub UserForm_Initialize() ¬O¤@¼Ëªº
¥Dµ{¦¡°Ï¶ô   ¬O¨ä¥L¼Ò²Õ¤¤
  1. Private Sub CommandButton1_Click()
  2. '
  3. '

  4.   Next
  5.    Cells(1, 3).Select
  6. UserForm1.Show   
  7. End Sub     
½Æ»s¥N½X

TOP

¦^´_ 8# GBKEE

©êºp ¤p§Ì»¡ªº¤£²M·¡~
¦A¦¸»¡©ú¤p§Ì ªººÃ´bÂI~
¦p¤W­±µ{¦¡©Ò¥Ü¡A¥Ø«e¬O§Q¥ÎCommandButton2 §@¬°Ä²µoÂI(§Y ÂICommandButton2  ¡A Label1.Caption   ¤~·|Åã¥Ü¥Ø«e®Ö¿ï¤§Checkbox ªº Caption­È )  
­Y¥HUserForm_Active  ¬°­ºªº¸Ü¡A¶Õ¥²·|²£¥Í¿ù»~(¦]©|¥¼ ²£¥Í 10*10 ­Ó Checkbox±±¨î¶µ )

ºÃ´bÂI¦p¤U
1.­Y·Q¦b 10*10 ­Ó Checkbox±±¨î¶µ  ²£¥Í«á¡AÂI¿ï¥ô¤@ Checkbox ¡A²£¥Í®ÄªG¦p¦P­ì©l CommandButton2 ¤§®ÄªG¬Û¦P¡A¦ý¤£¥Î³z¹L CommandButton ±±¨î¡A¸Ó¥Î¦óªÌ¤è¦¡´y¼g¤ñ¸û¾A·í¡C
2.­Y®Ö¿ï¬°½Æ¿ï¡A¸Ó¦p¦ó§PÂ_¡H

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

¥»©«³Ì«á¥Ñ mark15jill ©ó 2012-10-19 11:15 ½s¿è

¦^´_ 8# GBKEE
  1. Private Sub CommandButton2_Click()

  2.      Dim mycheckbox1 As MSForms.CheckBox

  3.      aois = ActiveSheet.Range("c1").CurrentRegion.Rows.Count

  4.      For gosj = 1 To aois

  5.         With Controls("Checkbox" & gosj)

  6.             If .Value = True Then

  7.                 Label1.Caption = "²{¦b®Ö¿ï¡G" & .Name

  8.             End If

  9.         End With

  10.      Next


  11. End Sub
½Æ»s¥N½X

  ¦h°µ¦h·Q¦h¾Ç²ß¡A¤Ö¬Ý¤Ö¿ù¤Ö°g³~

  ¦h°µ=¦h¦h½m²ß¡A¦h¦h½s¼g¡C
  ¦h·Q=·Q·Q¬°¤°»ò¤H®aµ{¦¡­n¨º¼Ë¼g¡A¦pªG´«¦¨¦Û¤v¡A¤S·|«ç¼g¡C
  ¦h¾Ç²ß=¾Ç²ß¤H®aªºµo°Ý¨Ã¸Ñµª¡A¾Ç²ß¤H®aªº¼gªk

  ¤Ö¬Ý=¥u¬Ý¤£°µ¤]ªPµM

TOP

        ÀR«ä¦Û¦b : ¦¨¥\¬OÀuÂIªºµo´§¡A¥¢±Ñ¬O¯ÊÂIªº²Ö¿n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD