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

[µo°Ý] ½Ð±Ð¦p¦ó¥ÎVBA¦b¥t¤@¤u§@ªí­pºâ¥Xµ²ªG¡H

¦^´_ 1# ji12345678
  1. Private Sub cbCal_Click()
  2.   Dim iSCol%, iTCol%, iNum%
  3.   Dim lSRow&, lTRow&
  4.   Dim sStr$
  5.   Dim shSou As Sheet1, shTar As Sheet3

  6.   Set shSou = Sheets("Á`ªí")
  7.   Set shTar = Sheets("ÅܰÊ")
  8.   
  9.   With shTar.Cells
  10.     .ClearContents
  11.     .Interior.ColorIndex = -4142
  12.   End With
  13.   
  14.   With shSou
  15.     iSCol = 2 ' ¤é´Á»P¼W´î¶q
  16.     Do While .Cells(1, iSCol) <> ""
  17.       shTar.Cells(1, iSCol) = .Cells(1, iSCol)
  18.       shTar.Cells(2, iSCol) = "¼W´î¶q"
  19.       iSCol = iSCol + 1
  20.     Loop
  21.     sStr = Cells(1, iSCol - 1).Address
  22.     sStr = Mid(sStr, 2, InStr(2, sStr, "$") - 2)
  23.     shTar.Columns("B:" & sStr).ColumnWidth = 8.38
  24.    
  25.     lSRow = 3 ' ¤u¯Z¦W
  26.     Do While .Cells(lSRow, 1) <> ""
  27.       shTar.Cells(lSRow, 1) = .Cells(lSRow, 1)
  28.       lSRow = lSRow + 1
  29.     Loop
  30.    
  31.     iSCol = 3
  32.     Do While .Cells(1, iSCol) <> ""
  33.       lSRow = 3
  34.       Do While .Cells(lSRow, 1) <> ""
  35.         sStr = .Cells(lSRow, 1)
  36.         
  37.         If Left(sStr, 1) <> "Á`" Then iNum = CInt(Mid(sStr, 2, Len(sStr) - 2)) Else iNum = 1
  38.         
  39.         With .Cells(lSRow, iSCol)
  40.          shTar.Cells(lSRow, iSCol) = .Value - .Offset(, -1)
  41.         End With
  42.         
  43.         With shTar.Cells(lSRow, iSCol)
  44.           Select Case .Value
  45.             Case Is > 0
  46.               If iNum > 9 Then .Interior.ColorIndex = 41 Else .Interior.ColorIndex = 38
  47.             Case 0
  48.               .Interior.ColorIndex = -4142
  49.             Case Is < 0
  50.               If iNum > 9 Then .Interior.ColorIndex = 46 Else .Interior.ColorIndex = 35
  51.           End Select ' ÂÅ 41 ¾ï 46 ºñ 35 ¯» 38
  52.         End With
  53.         lSRow = lSRow + 1
  54.       Loop
  55.       iSCol = iSCol + 1
  56.     Loop
  57.   End With
  58. End Sub
½Æ»s¥N½X
°Ý°ÝÃD-102.10.2-a.zip (14.43 KB)

TOP

        ÀR«ä¦Û¦b : «Ý¤H°h¤@¨B¡A·R¤H¼e¤@¤o¡A´N·|¬¡±o«Ü§Ö¼Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD