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

½Ð°Ý¨ÌÀx¦s®æ¼Æ­È±ø¥óÅã¥Ü¤å¦r¤Î­I´º¦âªº°ÝÃD

½Ð°Ý¨ÌÀx¦s®æ¼Æ­È±ø¥óÅã¥Ü¤å¦r¤Î­I´º¦âªº°ÝÃD

§Ú¼g¤F¤@¬q¤pµ{¦¡¥D­n¬O¨Ì¾ÚÀx¦s®æªº­È©ÒÄݪº°Ï¶¡¨Ó²£¥ÍÃC¦â¡A¦ý¦]¬°¦³¤£¦Pªº°Ï¶¡­È¤À¦¨¦n¦h°Ï¶ô¡A¨C¤@°Ïªº¤j¤p¤£¦P¡A¤À¯Åªº¼Æ¤]¤£¦P
µ{¦¡½X·§²¤¦p¤U
Sub color()
'²Ä¤@°Ï----------------------------------------------------------------
    Dim Rng As Range, F As Variant
    For Each F In ThisWorkbook.Sheets("sheet2").[b4:i15]
        
        If F > 800 Then
           F.Interior.ColorIndex = 40
           F.Font.ColorIndex = 3
           F.Font.Bold = True
        ElseIf F > 500 And F <= 800 Then
           F.Interior.ColorIndex = 36
           F.Font.ColorIndex = 3
           F.Font.Bold = True
        ElseIf F > 200 And F <= 500 Then
           F.Interior.ColorIndex = 19
           F.Font.ColorIndex = 3
           F.Font.Bold = True
   
        ElseIf F < -200 And F >= -500 Then
           F.Interior.ColorIndex = 24
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        ElseIf F < -500 And F >= -800 Then
           F.Interior.ColorIndex = 15
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        ElseIf F < -800 Then
           F.Interior.ColorIndex = 48
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        Else
         'F.Interior.ColorIndex = -4142 'µL©³¦â

           F.Interior.ColorIndex = 35 '
           F.Font.ColorIndex = 1
           F.Font.Bold = False
        End If
   Next
   
  For Each F In ThisWorkbook.Sheets("sheet2").[j4:l15]
        
        If F > 1600 Then
           F.Interior.ColorIndex = 40
           F.Font.ColorIndex = 3
           F.Font.Bold = True
        ElseIf F > 900 And F <= 1600 Then
           F.Interior.ColorIndex = 36
           F.Font.ColorIndex = 3
           F.Font.Bold = True
        ElseIf F > 400 And F <= 900 Then
           F.Interior.ColorIndex = 19
           F.Font.ColorIndex = 3
           F.Font.Bold = True
   
        ElseIf F < -400 And F >= -900 Then
           F.Interior.ColorIndex = 24
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        ElseIf F < -900 And F >= -1600 Then
           F.Interior.ColorIndex = 15
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        ElseIf F < -1600 Then
           F.Interior.ColorIndex = 48
           F.Font.ColorIndex = 11
           F.Font.Bold = True
        Else
         'F.Interior.ColorIndex = -4142 'µL©³¦â

           F.Interior.ColorIndex = 35 '
           F.Font.ColorIndex = 1
           F.Font.Bold = False
        End If
   Next
   ...........
«á­±ÁÙ¦³¡A¦ý³£¬O­«½Æªº¼gªk¡A½Ð°Ý­n¦p¦óÁYµuµ{¦¡½X»yªk? Book1.rar (13.28 KB)

¤W­zªº±¡§Î¥i¥H§Q¥Î Switch »P Choose ¨â­Ó¨ç¼Æ¨Ó¤j´T²¤Æµ{¦¡,
¥H¤U¶È¦C¥X²Ä¤@¤p¬qªºµ{¦¡,¨ä¾l¶È»ÝÅܧó¬ÛÃö¼Æ¦r«á¦A®M¥Î¤W¥h§Y¥i.

  Dim iRng%, F As Variant

  With ThisWorkbook.Sheets("sheet2")
    For Each F In .Range("b4:i15")
      iRng = Switch(F > 800, 1, F > 500 And F <= 800, 2, F > 200 And F <= 500, 3, F >= -200 And F <= 200, 4 _
         , F < -200 And F >= -500, 5, F < -500 And F >= -800, 6, F < -800, 7)
      F.Interior.ColorIndex = Choose(iRng, 40, 36, 19, 35, 24, 15, 48)
      F.Font.ColorIndex = Choose(iRng, 3, 3, 3, 1, 11, 11, 11)
      F.Font.Bold = Choose(iRng, True, True, True, False, True, True, True)
    Next

    For Each F In .Range("j4:l15")
    .
    .
    .
    Next

    .
    .
    .

  End With

TOP

¦^´_ 1# yuch8663
¸Õ¸Õ¬Ý
  1. Sub Color()
  2.    '¥Ü½d¨ì²Ä¤T°Ï----------------------------------------------------------------
  3.    Dim °Ï°ì As Range, Ar1, Ar2, Ar3, ­È, ©³¦â, ¦r¦â, i%
  4.    Set °Ï°ì = ThisWorkbook.Sheets("sheet2").[b4:i15,j4:l15,m4:n15]
  5.    '°Ï°ì¬O¦U°Ïªº¦ì¸m ½Ð­×§ï
  6.    Ar1 = Array(Array(800, 500, 200), Array(1600, 900, 400), Array(4000, 2500, 1000))
  7.    'Ar1 °}¦C ¨Ì§Ç¹ïÀ³¨ì¬O¦U°Ï¶ôªº­È
  8.    Ar2 = Array(Array(40, 36, 19, 24, 15, 48, 35), Array(40, 36, 19, 24, 15, 48, 35), Array(3, 22, 40, 43, 50, 10, 39))
  9.    'Ar2 °}¦C ¨Ì§Ç¹ïÀ³¨ì¬O¦U°Ï¶ô If ©Ò§PÂ_ªº©³¦âªº¯Á¤Þ­È
  10.    Ar3 = Array(Array(3, 11, 1), Array(3, 11, 1), Array(6, 3, 1))
  11.    'Ar3 °}¦C ¨Ì§Ç¹ïÀ³¨ì¬O¦U°Ï¶ô If ©Ò§PÂ_ªº¦rÅéÃC¦âªº¯Á¤Þ­È
  12.     For i = 0 To °Ï°ì.Areas.Count - 1   '¨Ì§Ç¦b °Ï°ìªº¦U°Ï¶ô
  13.         For Each F In °Ï°ì.Areas(i + 1).Cells  '¨Ì§Ç¦b °Ï¶ôªº¨C¤@­Ó Cell
  14.             ­È = Ar1(i): ©³¦â = Ar2(i): ¦r¦â = Ar3(i)   '¨ú±o°Ï¶ô©Ò¹ïÀ³¨ìªº°}¦C
  15.             F.Font.Bold = True
  16.             If F > ­È(0) Then
  17.                 F.Interior.ColorIndex = ©³¦â(0)
  18.                 F.Font.ColorIndex = ¦r¦â(0)
  19.             ElseIf F > ­È(1) And F <= ­È(0) Then
  20.                 F.Interior.ColorIndex = ©³¦â(1)
  21.                 F.Font.ColorIndex = ¦r¦â(0)
  22.             ElseIf F > ­È(2) And F <= ­È(1) Then
  23.                 F.Interior.ColorIndex = ©³¦â(2)
  24.                 F.Font.ColorIndex = ¦r¦â(0)
  25.             ElseIf F < -­È(2) And F >= -­È(1) Then
  26.                 F.Interior.ColorIndex = ©³¦â(3)
  27.                 F.Font.ColorIndex = ¦r¦â(1)
  28.             ElseIf F < -­È(1) And F >= -­È(0) Then
  29.                 F.Interior.ColorIndex = ©³¦â(4)
  30.                 F.Font.ColorIndex = ¦r¦â(1)
  31.             ElseIf F < -­È(0) Then
  32.                 F.Interior.ColorIndex = ©³¦â(5)
  33.                 F.Font.ColorIndex = ¦r¦â(1)
  34.             Else
  35.                 F.Interior.ColorIndex = ©³¦â(6)
  36.                 F.Font.ColorIndex = ¦r¦â(2)
  37.                 F.Font.Bold = False
  38.             End If
  39.         Next
  40.     Next
  41. End Sub
½Æ»s¥N½X

TOP

ÁÂÁÂGBKEE ª©¥D«ü¾É¡A³o­Ó°j°éªº¼gªk«Ü°ª¬ñ¡A¹ï§Ú¨Ó»¡¦³ÂIÃø²z¸Ñ¡A§Ú¸ÕµÛ´¢¼¯´¢¼¯¡AÁÂÁ¡C

TOP

­è­è¨Sª`·N¬Ýluhpro¼Ó¥Dªº¦^ÂÐluhpro ¼Ó¥Dªº¼gªk¦ü¥G§Ú¤ñ¸û®e©ö²z¸Ñ¡AÁÂÁ¡C

TOP

¦^´_ 5# yuch8663
½Ð°Ýluhpro ¼Ó¥D¡A§Ú°Ñ¬ãÀÀªº°µªk±N¤ÀÃþ¼Ð·Ç§ó§ï¬°¥t¤@­Ó°Ï¶ô°µ°Ñ·Ó¡A·|¦b¤U¦C¬õ¦r°Ï¥X²{¿ù»~¡A½Ð°Ý¬O¦ó­ì¦]?

Sub Color2() 'luhpro ¼Ó¥D«ü¾É
'¤W­zªº±¡§Î¥i¥H§Q¥Î Switch »P Choose ¨â­Ó¨ç¼Æ¨Ó¤j´T²¤Æµ{¦¡,'
'¥H¤U¶È¦C¥X²Ä¤@¤p¬qªºµ{¦¡,¨ä¾l¶È»ÝÅܧó¬ÛÃö¼Æ¦r«á¦A®M¥Î¤W¥h§Y¥i.

  Dim iRng%, F As Variant

  With ThisWorkbook.Sheets("sheet3")
    For Each F In .Range("b35:p46")
      iRng = Switch(F >= 0.06, 1, F >= 0.04 And F < 0.06, 2, F >= 0.02 And F < 0.04, 3, _
      F > 0 And F < 0.02, 4, F = 0, 5, F < 0 And F > -0.02, 6, _
         , F <= -0.02 And F > -0.04, 7, F <= -0.04 And F > -0.06, 8, F <= -0.06, 9)
      F.Offset(-30, 0).Interior.ColorIndex = Choose(iRng, 3, 46, 22, 40, -4142, 15, 43, 50, 10)
      F.Offset(-30, 0).Font.ColorIndex = Choose(iRng, 2, 2, 2, 1, 1, 1, 44, 44, 44)
      F.Offset(-30, 0).Font.Bold = Choose(iRng, True, True, True, False, False, False, True, True, True)
    Next '
  End With

End Sub

Book1.rar (20.33 KB)

TOP

¦^´_ 6# yuch8663

Excelªº»¡©ú
Switch ¨ç¼Æªº¤Þ¼Æ¦ê¦C¥]§t¦h¹ïªº¹Bºâ¦¡©M¼Æ­È¡A¹Bºâ¦¡¬O¥Ñ¥ª¦Ü¥k¥[¥H­pºâ¡A¦Ó¼Æ­È«h·|¦b¬ÛÁpªº¹Bºâ¦¡¬° True ®É¶Ç¦^¡C¦pªG¨ä¤¤¦³³¡¥÷¨S¦³¦¨¹ï¡A«h·|²£¥Í¤@­Ó°õ¦æ¤¤¿ù»~¡C¦pªG expr-1 ¬° True «h Switch ¶Ç¦^ value-1 ¡A¦pªG expr-1 ¬° False¡A¦ý expr-2 ¬° True¡A«h Switch ¶Ç¦^ value-2 ¡A¥H¦¹Ãþ±À¡C
Switch ·|¶Ç¦^¤@­Ó Null ­È¡A¦pªG¡G
¨S¦³¤@­Ó¹Bºâ¦¡¬° True.
²Ä¤@­Ó¬° True ªº¹Bºâ¦¡¡A¨ä¬Û¹ïÀ³±o­È¬° Null¡C
Switch ·|­pºâ©Ò¦³ªº¹Bºâ¦¡¡AÁöµM¥¦¥u·|¶Ç¦^¨ä¤¤ªº¤@­Ó­È¡A¦]¦¹±zÀ³¸Ó¯d·N©Ò²£¥Íªº°Æ§@¥Î¡A¨Ò¦p¡A¦³¬Y­Ó¹Bºâ¦¡·|¾É­P°£¥H¹s¡A¨º»ò´N·|µo¥Í¿ù»~¡C

TOP

ÁÂÁÂGBKEEª©¥Dªº¸Ñ»¡¡A¦ý¬O§Ú¤£¤Ó¤F¸Ñ¡A©Ò¿×ªº¹Bºâ¦¡¬O«ü¡AF >= 0.06¤¤ªº"¤j©ó"¡B"µ¥©ó"¡B"¤p©ó"³o¨Ç¶Ü?§ÚÀˬd¹L³o¤E²Õ¤À²Õ¨Ã¨S¦³­«Å|ªº³¡¤À¡A¬°¦óÁÙ¬O¦³»~?§Ú¸Õ¹Lluhpro ¼Ó¥Dªº¤è¦¡¦b­ì½d¨Ò¤¤¬O¥i¥H¹B¦æªº
ÃQ¦ó¼W¥[¤F¤G²Õ§PÂ_´N¤£¦æ?

TOP

¦^´_ 8# yuch8663
¤½¦¡¤Óªø·|¬Ý¨ì²´ªá ¦h¥X¤@­Ó ,
   iRng = Switch(F >= 0.06, 1, F >= 0.04 And F < 0.06, 2, F >= 0.02 And F < 0.04, 3, _
      F > 0 And F < 0.02, 4, F = 0, 5, F < 0 And F > -0.02, 6, _
        , F <= -0.02 And F > -0.04, 7, F <= -0.04 And F > -0.06, 8, F <= -0.06, 9)

   

TOP

¼Ò²Õ¤Æ©O ¸Õ¸Õ¬Ý!

Function SetCellInfo(ByVal fCell As Variant, ByVal iColorIndex As Integer, ByVal fColorIndex As Integer, ByVal fBold As Boolean)
    fCell.Interior.ColorIndex = iColorIndex '
    fCell.Font.ColorIndex = fColorIndex
    fCell.Font.Bold = fBold
End Function

    'Dim Rng As Range ³o­ÓÅܼƬO¦h¾lªº!
    Dim F As Variant
   
    For Each F In ThisWorkbook.Sheets("sheet2").[b4:i15]
        If F > 800 Then
            Call SetCellInfo(F, 40, 3, True)
        ElseIf F > 500 And F <= 800 Then
            Call SetCellInfo(F, 36, 3, True)
        ElseIf F > 200 And F <= 500 Then
            Call SetCellInfo(F, 19, 3, True)
        ElseIf F < -200 And F >= -500 Then
            Call SetCellInfo(F, 24, 11, True)
        ElseIf F < -500 And F >= -800 Then
            Call SetCellInfo(F, 15, 11, True)
        ElseIf F < -800 Then
            Call SetCellInfo(F, 48, 11, True)
        Else
            Call SetCellInfo(F, 35, 1, False)
        End If
    Next F
­Y¬O§Ú¦^µª¡A¨Ï±zº¡·N¡A½Ð±zÅý§Úª¾¹D¡I                  
­Y¬O§Úªº¦^ÂСA±z¤´¦³¨ä¥L¨£¸Ñ¡A¤]½Ð±z¤£¶Þ«ü±Ð¡I

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD