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

¦p¦ó§ïµ½³o¬qµ{¦¡¡AÅý°õ¦æ®Ä²v´£¤É¡H

¦p¦ó§ïµ½³o¬qµ{¦¡¡AÅý°õ¦æ®Ä²v´£¤É¡H

  1. Sub test()
  2. '¦~«×¤ÀªR¡A¶}¾P«e3¦W
  3.     Application.ScreenUpdating = False
  4.     W = [W]
  5.     r = [A1].CurrentRegion.Rows.Count
  6.     Range("B7:M" & r).ClearContents
  7.     Range("B2:M3").ClearContents
  8.     myyear = [A1].Value
  9.     For c = 2 To 13
  10.         mymonth = myyear & "/" & Trim(Cells(1, c).Value)
  11.         income = 0
  12.         expense = 0
  13.         pay = 0
  14.         v = 11
  15.         With Sheets("DataCopy")
  16.             er = .[A100000].End(3).Row
  17.             For r = 2 To er
  18.                 If myyear & "/" & Format(.Cells(r, 1).Value, "m¤ë¥÷") = mymonth Then
  19.                     money = Val(.Cells(r, 3).Value)
  20.                     Select Case .Cells(r, 2).Value
  21.                         Case "¦¬¤J": income = income + money
  22.                         Case "¤ä¥X": expense = expense + money
  23.                         Case "¤À´Á¥I´Ú": expense = expense + money: pay = pay + 1
  24.                     End Select
  25.                     myitem = .Cells(r, 4).Value
  26.                     If .Cells(r, 2).Value <> "¦¬¤J" Then
  27.                         Set cell = Columns(c + 1).Find(myitem)
  28.                         If Not cell Is Nothing Then
  29.                             cell.Offset(, -1).Value = cell.Offset(, -1).Value + money
  30.                         Else
  31.                             Cells(v, c).Value = money
  32.                             Cells(v, c + 1).Value = .Cells(r, 4).Value
  33.                             v = v + 1
  34.                         End If
  35.                     End If
  36.                 End If
  37.             Next r
  38.             If Cells(11, c) <> "" Then
  39.                 Set rng = Range(Cells(11, c), Cells(v - 1, c + 1))
  40.                 rng.Sort key1:=Cells(11, c), order1:=xlDescending
  41.                 X = 0
  42.                 v = 11
  43.                 Do Until Cells(v, c).Value = ""
  44.                     If InStr(W, Cells(v, c + 1)) = 0 Then
  45.                         If X < 3 Then
  46.                             X = X + 1
  47.                             Cells(X + 6, c).Value = X & ". " & Cells(v, c + 1).Value & " / " & Cells(v, c).Value & "¤¸"
  48.                         End If
  49.                     End If
  50.                     Cells(v, c).Value = v - 10 & ". " & Cells(v, c + 1).Value & " / " & Cells(v, c).Value & "¤¸"
  51.                     Cells(v, c + 1).Value = ""
  52.                     v = v + 1
  53.                 Loop
  54.             End If
  55.         End With
  56.         Cells(2, c).Value = IIf(income <> 0, income, "")
  57.         Cells(3, c).Value = IIf(expense <> 0, expense, "")
  58.         Cells(10, c).Value = pay
  59.     Next c
  60.     Application.ScreenUpdating = True
  61. '¦Û°Ê´«¦æ
  62.     Rows("7:100000").EntireRow.AutoFit
  63.     Application.ScreenUpdating = True
  64. End Sub
½Æ»s¥N½X
¥H¤W¬O¬Y¦ì¦Ñ®v¼¶¼g¡A¦³ÂI§Ñ¤F¬O½Ö(¥¢Â§¤F)¡A­ì¥»³£¥ÎXPªºExcel°õ¦æ¡A®Ä²v³£ÁÙOK¡A
´«¦¨2010«á¡A°õ¦æ¥H«á·|Åܱo«D±`«D±`ªººC¡A¤£ª¾¹D¦³¨S¦³¿ìªk§ïµ½¡AÁÂÁ¡I

¦^´_ 1# av8d


    ¬yµ{ªº³¡¤À§Ú¨S¦³¤ÀªR,¦ý§Ú½T©wªº¬O¥i¥H¥Î°}¦C·|°õ¦æªº§ó§Ö
¦]¬°°}¦Cªº¹B§@³t«×·|¤ñŪ¨úCELLS§ÖN­¿

¦b¶}ÀYªº¦a¤è¥ý
AR=[a1].currentregion'¦¹¦æ­·ÀI¦b©ó¤¤Â_ªºÀx¦s®æ,­Y¦³¤¤Â_ªºÀx¦s®æ½Ð¥Î¤U¤è
AR=[a1].resize(x,y)'¥i¦Û­q°}¦C¤j¤p
¤§«áAR(1,1) ´N·|µ¥©ó cells(1,1)=>¦]¦¹±Nµ{¦¡½X¨ú¥N§Y¥i,  ¦Ó.valueªº³¡¤À«h¥i§R°£

with ªº³¡¤À¤@¼Ë¥ÎAR2=.[a1].currentregion'§Y¥i,AR2(1,1)=.cells(1,1)
¦ý«á­±sortªº³¡¤À­n«O¯d­ì¥»ªºCELLS¤~¤£·|¦³°ÝÃD
¥H¤Î³Ì«á¿é¥Xªº.cells.value¦]¬°­n¿é¥X,·íµM¤£¥i¨ú¥N¬°°}¦C
PKKO

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD