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

[µo°Ý] «¬ºA¤£²Å©M

[µo°Ý] «¬ºA¤£²Å©M

¦U¦ì«e½ú¦n

½Ð°Ý³o¬q»yªk ¬õ¦r³¡¥÷­þÃ伶¼g¿ù»~  ¥L¤@ª½¥X²{«¬ºA¤£²Å©M

¬õ¦r³¡¥÷ §Ú­n¼g¤Jªº±ø¥ó¦¡¬OB2³o­ÓÀx¦s®æªº¦ì¸m

ÁٽЦU¦ì«e½ú¦h¦h«üÂI
  1. Sub ¿ûµ¬­p():D
  2.   
  3. Dim I%, J%, k%                         '«Å§iÅܼÆ
  4. Dim current As Worksheet
  5. 'For Each current In Worksheets         '¹ï©Ò¦³¬¡­¶Ã¯§@³B²z
  6. 'current.Select

  7. J = 1
  8. Do While Cells(1, J) <> "¶q´ú­È"        'º¡¨¬±ø¥ó®É°õ¦æ¥H¤U°Ê§@
  9. J = J + 1
  10. Loop
  11. J = J - 1
  12. Columns(J).Insert Shift:=xlToRight     '¦V¥k´¡¤J¤@Äæ
  13. k = Range("a:a").End(xlDown).Row       '¨ú±oAÄæ³Ì«á¤@®æ¦³¸ê®Æªº­È
  14. Range(Columns(J + 1).Rows(2), Columns(J + 2).Rows(k)).Clear  'Äæ¦ì¼Æ­È²M°£
  15. Cells(1, J) = Now()                    'Áä¤J®É¶¡
  16. For I = 2 To k Step 1
  17.     If Cells(I, (J - 1)) - Cells(I, (J - 2)) > 0 Then
  18.         Randomize                      '­Y¬Û´î¤j©ó0 ¶]­t¶Ã¼Æ
  19.         Cells(I, J) = Round(((-1 - -3) * Rnd + -3), 1) + Cells(I, (J - 1))
  20.             ElseIf Cells(I, (J - 1)) - Cells(I, (J - 2)) < 0 Then
  21.                 Randomize              '­Y¬Û´î¤p©ó0 ¶]¥¿¶Ã¼Æ
  22.                 Cells(I, J) = Round(((2 - 1) * Rnd + 1), 1) + Cells(I, (J - 1))
  23.         Else
  24.             Cells(I, J) = ""           '¥H¤W±ø¥ó¤£¦¨¥ß«h¬°ªÅ¦r¦ê
  25.     End If
  26. If Cells(I, J) - Cells(I, (J - 2)) = 0 Then
  27.     Call µ¥©ó0
  28. End If
  29.     With Cells(I, J + 1)               '¨D±o¨âªÌ®t²§
  30.         .Formula = "=IF(ISBLANK(" & .Offset(0, -1).Address & "),""""," & .Offset(0, -1).Address & " - " & .Offset(0, -2).Address & ")"
  31.         With Cells(I, J + 2)           '¨D±o¶q´ú­È
  32.             .Formula = "=IF(ISBLANK(" & .Offset(0, -2).Address & "),""""," & "c" & I & "+(Round(" & .Offset(0, -2).Address & [color=Red]" / " & .Offset(0, ".End(xlleft)+2).Address,0) ")[/color]
  33.         End With
  34.     End With
  35. If Cells(I, J) = "" Then               '·í¦¹¬°ªÅ¦r
  36.     Cells(I, J + 1) = ""               '«hÅã¥ÜªÅ¦r¦ê
  37.     Cells(I, J + 2) = ""
  38. End If
  39. Next I
  40. Set current = Nothing                  'ÄÀ©ñª«¥óÅܼÆ
  41. 'Next current
  42. MsgBox "Worksheets working Success!!"  '°T®§´£¥Ü
  43. End Sub
½Æ»s¥N½X

¦U¦ì«e½ú¦n

½Ð°Ý³o¬q»yªk ¬õ¦r³¡¥÷­þÃ伶¼g¿ù»~  ¥L¤@ª½¥X²{«¬ºA¤£²Å©M

¬õ¦r³¡¥÷ §Ú­n¼g¤Jªº±ø¥ó¦¡¬O ...
alex520188 µoªí©ó 2014-11-19 10:51

¬õ¦r¬O«ü For Each current In Worksheets  ³o¤@¦æ¶Ü?
§Ú°õ¦æ°_¨Ó¨S°ÝÃD³á.
  1. Sub ¿ûµ¬­p()
  2.   
  3. Dim I%, J%, k%                         '«Å§iÅܼÆ
  4. Dim current As Worksheet
  5. For Each current In Worksheets         '¹ï©Ò¦³¬¡­¶Ã¯§@³B²z
  6. current.Select

  7. J = 1
  8. Do While Cells(1, J) <> "¶q´ú­È"        'º¡¨¬±ø¥ó®É°õ¦æ¥H¤U°Ê§@
  9. J = J + 1
  10. Loop
  11. J = J - 1
  12. Columns(J).Insert Shift:=xlToRight     '¦V¥k´¡¤J¤@Äæ
  13. k = Range("a:a").End(xlDown).Row       '¨ú±oAÄæ³Ì«á¤@®æ¦³¸ê®Æªº­È
  14. Range(Columns(J + 1).Rows(2), Columns(J + 2).Rows(k)).Clear  'Äæ¦ì¼Æ­È²M°£
  15. Cells(1, J) = Now()                    'Áä¤J®É¶¡
  16. For I = 2 To k Step 1
  17.     If Cells(I, (J - 1)) - Cells(I, (J - 2)) > 0 Then
  18.         Randomize                      '­Y¬Û´î¤j©ó0 ¶]­t¶Ã¼Æ
  19.         Cells(I, J) = Round(((-1 - -3) * Rnd + -3), 1) + Cells(I, (J - 1))
  20.             ElseIf Cells(I, (J - 1)) - Cells(I, (J - 2)) < 0 Then
  21.                 Randomize              '­Y¬Û´î¤p©ó0 ¶]¥¿¶Ã¼Æ
  22.                 Cells(I, J) = Round(((2 - 1) * Rnd + 1), 1) + Cells(I, (J - 1))
  23.         Else
  24.             Cells(I, J) = ""           '¥H¤W±ø¥ó¤£¦¨¥ß«h¬°ªÅ¦r¦ê
  25.     End If
  26. If Cells(I, J) - Cells(I, (J - 2)) = 0 Then
  27.     'Call µ¥©ó0
  28. End If
  29.     With Cells(I, J + 1)               '¨D±o¨âªÌ®t²§
  30.         .Formula = "=IF(ISBLANK(" & .Offset(0, -1).Address & "),""""," & .Offset(0, -1).Address & " - " & .Offset(0, -2).Address & ")"
  31.         With Cells(I, J + 2)           '¨D±o¶q´ú­È
  32.             '.Formula = "=IF(ISBLANK(" & .Offset(0, -2).Address & "),""""," & "c" & I & "+(Round(" & .Offset(0, -2).Address & [color=Red]" / " & .Offset(0, ".End(xlleft)+2).Address,0) ")[/color]
  33.         End With
  34.     End With
  35. If Cells(I, J) = "" Then               '·í¦¹¬°ªÅ¦r
  36.     Cells(I, J + 1) = ""               '«hÅã¥ÜªÅ¦r¦ê
  37.     Cells(I, J + 2) = ""
  38. End If
  39. Next I
  40. Set current = Nothing                  'ÄÀ©ñª«¥óÅܼÆ
  41. Next current
  42. MsgBox "Worksheets working Success!!"  '°T®§´£¥Ü
  43. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤H­n¦Û·R¡A¤~¯à·R´¶¤Ñ¤Uªº¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD