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

¦Û°Ê¶ñº¡¿ï¶µ«ö¶s

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-4-9 16:15 ½s¿è

¦^´_ 24# caichen3
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Private Sub CommandButton4_Click()
  3.     Dim xR As Integer, Ar(1 To 5), xi As Integer, OB As OLEObject
  4.     With ActiveSheet
  5.         .CommandButton4.Placement = xlFreeFloating
  6.         xR = .Cells(Rows.Count, "A").End(xlUp).Row         'AÄæ³Ì«á¦³¸ê®Æªº¦C¸¹
  7.         Ar(1) = xR & "«D±`¤£­«­n" & "(" & xR & ")"
  8.         Ar(2) = xR & "¤£­«­n" & "(" & xR & ")"
  9.         Ar(3) = xR & "´¶³q" & "(" & xR & ")"
  10.         Ar(4) = xR & "­«­n" & "(" & xR & ")"
  11.         Ar(5) = xR & "«D±`­«­n" & "(" & xR & ")"
  12.         For xi = 1 To 5
  13.             With .Cells(xR + 1, "A").Offset(, xi + 2)      '¥HAÄ欰¥D   ³Ì«á¦³¸ê®Æªº¦C¸¹ + 1¦Cªº¦ì¸m
  14.                 Set OB = ActiveSheet.OLEObjects.Add(ClassType:="Forms.OptionButton.1", Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
  15.                 OB.Object.Caption = Ar(xi)
  16.                 OB.Object.GroupName = "Row" & xR + 1   '¹ïÀ³¦C¸¹
  17.             End With
  18.          Next
  19.         With .Range(.Cells(2, "A"), .Cells(xR + 1, "A")).Resize(, 8) 'A2:H & xR + 1
  20.             .Columns(1) = "=row()-1"                                 'AÄ椽¦¡ ¨Ì¦C¸¹-1
  21.             .Columns(1) = .Columns(1).Value                           '±N¤½¦¡ Âন ­È
  22.             .Columns(1).Interior.ColorIndex = 15
  23.             .Borders.LineStyle = xlContinuous
  24.             .Borders(xlEdgeBottom).Weight = xlThick
  25.             .Borders(xlEdgeRight).Weight = xlThick
  26.             .Borders(xlEdgeLeft).Weight = xlThick
  27.         End With
  28.     End With
  29. End Sub
  30. Private Sub CommandButton5_Click()
  31.     Dim xR As Integer, OB As OLEObject, Sp As Variant, MyStr As String
  32.     With ActiveSheet
  33.         .CommandButton5.Placement = xlFreeFloating
  34.          If ActiveCell.Row > .Cells(Rows.Count, "A").End(xlUp).Row Then Exit Sub  '¤£¬O½d³ò¤¤
  35.         xR = ActiveCell.Row                                          '¨ú±o §@¥ÎÀx¦s®æªº¦C¸¹
  36.         For Each OB In ActiveSheet.OLEObjects
  37.             If OB.Name Like "OptionButton*" Then
  38.                 If OB.Object.GroupName = "Row" & xR Then OB.Delete  '§R°£§@¥ÎÀx¦s®æªº¦C¸¹ ¸s²Õ
  39.             End If
  40.         Next
  41.         .Cells(xR, "A").Resize(, 8).Delete xlUp                      '§R°£§@¥ÎÀx¦s®æ AÄæ¨ìHÄæ
  42.         xR = .Cells(Rows.Count, "A").End(xlUp).Row
  43.         With .Range(.Cells(2, "A"), .Cells(xR, "A")).Resize(, 8)     'A2:H & xR :½d³ò¤¤
  44.             .Columns(1) = "=row()-1"
  45.             .Columns(1) = .Columns(1).Value
  46.             .Columns(1).Interior.ColorIndex = 15
  47.             .Borders.LineStyle = xlContinuous
  48.             .Borders(xlEdgeBottom).Weight = xlThick
  49.             .Borders(xlEdgeRight).Weight = xlThick
  50.             .Borders(xlEdgeLeft).Weight = xlThick
  51.         End With
  52.         For Each OB In .OLEObjects                      '­«·s°t¸m OptionButtonªº¤å¦r ¤Î GroupName
  53.             If OB.Name Like "OptionButton*" Then
  54.                 Sp = Split(OB.TopLeftCell.Address(), "$")  '©î¸Ñ OptionButton ©Ò¦bµ´¹ï¦ì ¸m¨Ò: $D$5
  55.                 Select Case Sp(1)
  56.                     Case "D"
  57.                         MyStr = "«D±`¤£­«­n"
  58.                     Case "E"
  59.                         MyStr = "¤£­«­n"
  60.                     Case "F"
  61.                         MyStr = "´¶³q"
  62.                     Case "G"
  63.                         MyStr = "­«­n"
  64.                     Case "H"
  65.                         MyStr = "«D±`­«­n"
  66.                 End Select
  67.                 OB.Object.Caption = Sp(2) - 1 & MyStr & "(" & Sp(2) - 1 & ")"
  68.                 OB.Object.GroupName = "Row" & Sp(2)    '¹ïÀ³¦C¸¹
  69.             End If
  70.         Next
  71.     End With
  72. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤£­n¤p¬Ý¦Û¤v¡A¦]¬°¤H¦³µL­­ªº¥i¯à¡C
ªð¦^¦Cªí ¤W¤@¥DÃD