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

[µo°Ý] ELSEIF»PDO WHILE±_ª¬°j°é¨Ó§PÂ_¥[Á`

¥»©«³Ì«á¥Ñ yen956 ©ó 2014-4-15 09:57 ½s¿è

¦^´_ 1# wiemanson
¤£ª¾¹D§Aªº·N«ä¬O¤£¬O³o¼Ë?
°õ¦æµ²ªG:
¬õ        ºñ        ÂÅ        ¶À        All
3        5        1        5        10
¦pªG¬O, ¸Õ¸Õ¬Ý:
Sub aa()
Dim x, sum1, sum2, sum3, sum4, sum5, sum6 As Long
x = 2
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0
sum5 = 0
Do While Cells(x, 1) <> ""
    'If .. Else ¨ã±Æ¥L, °õ¦æ¤F Cells(x, 4) = "·s", ´N¤£·|°õ¦æ¨ä¥Lªº
    If Cells(x, 4) = "·s" Then
    sum5 = sum5 + Cells(x, 2).Value
    End If
    '¦P¼Ë Cells(x, 3) = "¤j", ¤]¤£¯à¦b IF...Else ¤º
    If Cells(x, 3) = "¤j" Then
    sum2 = sum2 + Cells(x, 2).Value
    End If
   
    If Cells(x, 1) = "¬õ" Then
    sum1 = sum1 + Cells(x, 2).Value
    ElseIf Cells(x, 1) = "¬õ¬õ" Then
    sum1 = sum1 + Cells(x, 2).Value
    ElseIf Cells(x, 1) = "ºñ" Then
    sum2 = sum2 + Cells(x, 2).Value
    ElseIf Cells(x, 1) = "ÂÅ" Then
    sum3 = sum3 + Cells(x, 2).Value
    ElseIf Cells(x, 1) = "¶À" Then
    sum4 = sum4 + Cells(x, 2).Value
    Else
'¨S§@¥Î§a?
    sum1 = sum1 + 0
    sum2 = sum2 + 0
    sum3 = sum3 + 0
    sum4 = sum4 + 0
    sum5 = sum5 + 0

    End If
    x = x + 1
Loop
Cells(3, 5) = sum1
Cells(3, 6) = sum2
Cells(3, 7) = sum3
Cells(3, 8) = sum4
Cells(3, 9) = sum5
End Sub
'¦ý¤£ª¾ "ºñ","¤j" ¦P±Æ®É, §A·Q«ç»ò³B²z?
¤S, sum1, sum2, sum3, sum4, sum5, sum6 ¤@¾ã±ÆÅܼÆ,
¥iª½±µ¥Î [E3], [F3],[G3],... ¥N´À.
¸Õ¸Õ¬Ý:
  1. Private Sub CommandButton1_Click()
  2.     Dim x As Integer
  3.     x = 2
  4.     Range("E3:I3") = 0
  5.     Do While Cells(x, 1) <> ""
  6.         If Cells(x, 4) = "·s" Then
  7.             [I3] = [I3] + Cells(x, 2).Value
  8.         End If
  9.         If Cells(x, 3) = "¤j" Then
  10.             [F3] = [F3] + Cells(x, 2).Value
  11.         End If
  12.         If Cells(x, 1) = "¬õ" Or Cells(x, 1) = "¬õ¬õ" Then
  13.             [E3] = [E3] + Cells(x, 2).Value
  14.         ElseIf Cells(x, 1) = "ºñ" Then
  15.             [F3] = [F3] + Cells(x, 2).Value
  16.         ElseIf Cells(x, 1) = "ÂÅ" Then
  17.             [G3] = [G3] + Cells(x, 2).Value
  18.         ElseIf Cells(x, 1) = "¶À" Then
  19.             [H3] = [H3] + Cells(x, 2).Value
  20.         End If
  21.         x = x + 1
  22.     Loop
  23. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : °ß¨ä´L­«¦Û¤vªº¤H¡A¤~§ó«i©óÁY¤p¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD