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

[µo°Ý] ¦p¦ó¨ú±o³Ìªñªº»Ý¨D¤é´Á¥H¤Î¼Æ¶q

¦^´_ 1# adam2010
¸Õ¸Õ¬Ý¡G
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     Dim ¦b»s¶q, »Ý¨D¶q As Long
  3.     Dim r1, c1 As Integer
  4.    
  5.     '¦pªG ¦b»s¶q(ÄæB) ©Î »Ý¨D¶q(ÄæG¥H«á) ¦³²§°Ê, «h
  6.     If Target.Column = 2 Or Target.Column > 6 Then
  7.         r1 = Target.Row    '¸ê®Æ²§°Ê©Ò¦b¦C
  8.         ¦b»s¶q = Cells(r1, 2)
  9.         »Ý¨D¶q = 0
  10.         c1 = 6
  11.         Do
  12.             c1 = c1 + 1
  13.             »Ý¨D¶q = »Ý¨D¶q + Cells(r1, c1)
  14.         Loop Until »Ý¨D¶q > ¦b»s¶q
  15.         Cells(r1, 5) = Cells(1, c1)  '«Ý§ë¤é´Á
  16.         Cells(r1, 6) = »Ý¨D¶q - ¦b»s¶q '«Ý§ë¼Æ¶q
  17.     End If
  18. End Sub
½Æ»s¥N½X
ps:
1. ¬°¦ó D2 ¤£¬O =C2-B2, ¦Ó¬O  =B2+C2?(µ§»~?)
2. Á`¶q¤½¦¡(CD2)»P C2¤½¦¡¤@¼Ë, ¥i§R, («O¯dC2¤½¦¡§Y¥i, §ó¦³¼u©Ê)

TOP

¥»©«³Ì«á¥Ñ yen956 ©ó 2014-6-7 12:44 ½s¿è

§ó¥¿, ¼W¥[¤@¦C(ÁקK¿ù»~²£¥Í):
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ¦b»s¶q, »Ý¨D¶q As Long
    Dim r1, c1 As Integer
   
    '¦pªG ¦b»s¶q(ÄæB) ©Î »Ý¨D¶q(ÄæG¥H«á) ¦³²§°Ê, «h
    If Target.Column = 2 Or Target.Column > 6 Then
        r1 = Target.Row    '¸ê®Æ²§°Ê©Ò¦b¦C
        If Not IsNumber(Cells(r1, 2)) Then Exit Sub
        ¦b»s¶q = Cells(r1, 2)
        »Ý¨D¶q = 0
        c1 = 6
        Do
            c1 = c1 + 1
            »Ý¨D¶q = »Ý¨D¶q + Cells(r1, c1)
        Loop Until »Ý¨D¶q > ¦b»s¶q
        Cells(r1, 5) = Cells(1, c1)  '«Ý§ë¤é´Á
        Cells(r1, 6) = »Ý¨D¶q - ¦b»s¶q '«Ý§ë¼Æ¶q
    End If
End Sub

TOP

¦^´_ 9# adam2010
©êºp, À³¸Ó¥[¤W Application.IsNumber ¤~¹ï!!
        If Not Application.IsNumber(Cells(r1, 2)) Then Exit Sub

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD