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

½Ð±Ð¨Ì§Ç(¤é«e±µªñªº¥ý¦©)±N®w¦s¶q¦©°£ªº¼gªk

½Ð±Ð¨Ì§Ç(¤é«e±µªñªº¥ý¦©)±N®w¦s¶q¦©°£ªº¼gªk

½Ð°Ý¦U¦ì°ª¤â¡A§Úªº­ì©lÀɮתºD¸òEÄæ¦ì¬O®w¦s¥H¤Î«Ý¤J®wªº¶q¡AHÄæ°_¬O­q³æ»Ý¨D¤é

»Ý­n¥ý¾ã²z¬°~
¦p:A001ªº®w¦s+«Ý¤J®w=500¡A¥æ´Á»Ý¨D1/31=2593¡A½Õ¾ã¬°®w¦s+«Ý¤J®w=0¡A¥æ´Á»Ý¨D1/31=2093
     A003ªº®w¦s+«Ý¤J®w=700¡A¥æ´Á»Ý¨D1/30=500¡A½Õ¾ã¬°®w¦s+«Ý¤J®w=200¡A¥æ´Á»Ý¨D1/30=0
     A005ªº®w¦s+«Ý¤J®w=170¡A¥æ´Á»Ý¨D1/18=50,1/22=60,1/28=769¡A½Õ¾ã¬°®w¦s+«Ý¤J®w=0¡A¥æ´Á»Ý¨D1/18=0,1/22=0,1/28=709

¦©®w¦s°ÝÃD.rar (5.01 KB)
Adam

¦^´_ 1# adam2010
¬Ý¤F¦n¤[¤~©ú¥Õ·N«ä , ´N¬O§â®w¦sª«®Æ¤À°t¨ì¦U­q³æ»Ý¨D«á¦©±¼?
  1. Sub balance()
  2. Dim rStart, rEnd, cStart, cEnd
  3. Dim ar1, ar2
  4. Dim minValue

  5. rStart = 3  'ª«®Æ¶}©l¦C
  6. rEnd = ActiveSheet.[a2].End(xlDown).Row - 1 'ª«®Æµ²§ô¦C
  7. cStart = 8  '¤é´Á¶}©lÄæ
  8. cEnd = ActiveSheet.[a2].End(xlToRight).Column - 1 '¤é´Áµ²§ô¦C

  9. With ActiveSheet
  10.     ar1 = .Range(.Cells(rStart, "D"), .Cells(rEnd, "E")).Value  '®w¦s/«Ý¤J®w ¸ê®Æ
  11.     ar2 = .Range(.Cells(rStart, cStart), .Cells(rEnd, cEnd)).Value    '­q³æ»Ý¨D¸ê®Æ
  12.     For i = LBound(ar2, 1) To UBound(ar2, 1)
  13.         For j = LBound(ar2, 2) To UBound(ar2, 2)
  14.             minValue = Application.Min(ar2(i, j), ar1(i, 1))
  15.             If minValue <> 0 Then
  16.                 ar2(i, j) = ar2(i, j) - minValue
  17.                 ar1(i, 1) = ar1(i, 1) - minValue
  18.             End If
  19.             
  20.             minValue = Application.Min(ar2(i, j), ar1(i, 2))
  21.             If minValue <> 0 Then
  22.                 ar2(i, j) = ar2(i, j) - minValue
  23.                 ar1(i, 2) = ar1(i, 2) - minValue
  24.             End If
  25.         Next
  26.     Next
  27.     '¼g¦^¤u§@ªí
  28.     .Cells(rStart, "D").Resize(UBound(ar1, 1), UBound(ar1, 2)).Value = ar1
  29.     .Cells(rStart, cStart).Resize(UBound(ar2, 1), UBound(ar2, 2)).Value = ar2
  30. End With
  31. End Sub
½Æ»s¥N½X

TOP

·PÁÂstillfish00¤j~¨S¿ù!
¯u·Q¥s±z¤@Án~¯«
¤Ó·PÁ¤F!
Adam

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¤£¤@©w²y²y¬O¦n²y¡A¦ý¬O¦³¾ú½mªº±j¥´ªÌ¡AÀH®É³£¥i¥H´§´Î¡C
ªð¦^¦Cªí ¤W¤@¥DÃD