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

[µo°Ý] (¤w¸Ñ¨M)VBA ¯S©w²Å¸¹¤Î¤å¦r³]©w µ{¦¡½Ð±Ð

[µo°Ý] (¤w¸Ñ¨M)VBA ¯S©w²Å¸¹¤Î¤å¦r³]©w µ{¦¡½Ð±Ð

¥»©«³Ì«á¥Ñ wind6424 ©ó 2011-10-14 16:32 ½s¿è

·Q½Ð±Ð¦U¦ì¤j¤j¯àÀ°¦£¬Ý¤@¤U
¤U­±VBA ¨º¸Ì¦³°ÝÃD,
   
§Úªº¥Øªº¬O§Æ±æ±NÀx¦s®æ¤¤
[test1] ¤§«eªº¤å¦rÅܦ¨ÂŦâ¤Î¦rÅé¥[²Ê
µM«á¨C­Ó[xxxx] ¤¤¬A¸¹¤º§t¬A¸¹¤Î¤å¦r³£³]¬°¶Â¦â¤Î¥[²Ê
¨ä¥Lªº¤å¦r¤£ÅÜ
³o­Óµ{¦¡¦b¤@¶}ÀYªº¤å¦r¬O¤¤¤å®É°õ¦æ³£¨S°ÝÃD,
¦ý¬O¹J¨ì¶}ÀY¬O­^¤å©Î¬O¼Æ¦r®É,
´N·|µo¥Í°£¤F¤¤¬A¸¹¤º¤Î¤å¦r¬O¦p³]©wªº¥~
¨ä¥¦¤å¦r³£Åܦ¨ÂŦâ¤Î¥[²Ê,
¤£ª¾¹D¬O¨º¸ÌÁٻݭn­×§ï°ÝÃD,
½Ð¦U¦ì«e½ú«ü¾É¤@¤U
ÁÂÁÂ

Àx¦s®æ¤º®e¦p¤U:
abscde
[test1]:
1.qwe
2.asd
[test2]:
qwe
[test3]:
sddf

VBA µ{¦¡:
With Sheet1.Cells(y, x)
        .Font.ColorIndex = 0
        .Font.Bold = False

        theText = .Text   'theText
  
        lngS = InStr(1, .Text, "[", 1) - 1
        
        .Characters(1, lngS).Font.ColorIndex = 5
        .Characters(1, lngS).Font.Bold = True
        
        Do While theText Like "*[[]*]*"
            
            lngS = InStr(lngS, .Text, "[")
               
            lngLen = VBA.InStr(lngS, .Text, "]") - lngS + 2
            
            .Characters(lngS, lngLen).Font.ColorIndex = 1
            .Characters(lngS, lngLen).Font.Bold = True
            
            lngS = lngS + lngLen
            theText = .Characters(lngS).Text

        Loop
   End With

¦^´_ 1# wind6424
  1. Sub Ex()
  2.     Dim Y, X, A, A1
  3.     Y = 1: X = 1
  4.     Do While Sheet1.Cells(Y, X) <> ""
  5.         With Sheet1.Cells(Y, X)
  6.             .Font.ColorIndex = 0
  7.             .Font.Bold = False
  8.             A = InStr(.Text, "[")
  9.             A1 = InStr(.Text, "]")
  10.             If A > 0 And A1 > 0 Then
  11.                 .Characters(A, A1 - A + 1).Font.ColorIndex = 5
  12.                 .Characters(A, A1 - A + 1).Font.Bold = True
  13.             End If
  14.             Y = Y + 1
  15.         End With
  16.    Loop
  17. End Sub
½Æ»s¥N½X

TOP

  1. Sub nn()
  2. Dim A As Range, y%
  3. For Each A In Range([A1], Cells(Rows.Count, 1).End(xlUp))
  4. A.Font.Bold = False
  5. A.Font.ColorIndex = 0
  6. i = 1
  7. Do Until Mid(A, i, 1) = "["
  8.   With A.Characters(i, 1).Font
  9.      .Bold = True
  10.      .ColorIndex = 5
  11.   End With
  12.   i = i + 1
  13. Loop
  14. s = InStr(A, "[")
  15. y = InStr(s, A, "]")
  16. Do Until s = 0
  17. A.Characters(s + 1, y - s - 1).Font.Bold = True
  18. s = InStr(y, A, "[")
  19. If s > 0 Then y = InStr(s, A, "]")
  20. Loop
  21. Next
  22. End Sub
½Æ»s¥N½X
¦^´_ 1# wind6424
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ wind6424 ©ó 2011-10-14 16:29 ½s¿è

·PÁ¨â¦ìªO¥Dªº¨ó§U
±N¨â¦ìªºµ{¦¡½Xµ²¦X
§ï¦¨¦p¤U,¹êÅç¤F¤@¤U ok ¤F
¦b¨Ó±NCells(6, 8) ³o­Ó­×§ï¤@¤U,´N¥i¥H¤@¦¸³B²z¦h­ÓÄæ¦ì¤F
«D±`ªº·PÁÂ
  1. Sub test()
  2. Dim A As Range, y%
  3. Dim s

  4. For Each A In Cells(6, 8)

  5. A.Font.Bold = False
  6. A.Font.ColorIndex = 0

  7. s = InStr(A, "[")
  8. y = InStr(s, A, "]")

  9. A.Characters(1, s-1).Font.ColorIndex = 5
  10. A.Characters(1, s-1).Font.Bold = True

  11. Do Until s = 0
  12. A.Characters(s + 1, y - s - 1).Font.Bold = True
  13. s = InStr(y, A, "[")
  14. If s > 0 Then y = InStr(s, A, "]")
  15. Loop

  16. Next

  17. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# wind6424

¤£¹ï§a!
Cells(6,8)¥u°w¹ïH6¦¹¤@Àx¦s®æ
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ wind6424 ©ó 2011-10-14 16:46 ½s¿è
¦^´_  wind6424

¤£¹ï§a!
Cells(6,8)¥u°w¹ïH6¦¹¤@Àx¦s®æ
Hsieh µoªí©ó 2011-10-14 16:29


§Ú¬O¥ý¨Ï¥Î¨â¦ìª©¤j´£¨Ñªºµ{¦¡½X,¹ï¤@­ÓÄæ¦ì¹êÅç¬Ý¬Ý,
©Ò¥H¨ú¨â¦ìªº­Ó¤H»{¬°¤£¿ùªº³¡¥÷µ²¦X«á,
¦b¹êÅç¬Ý¬Ý¨S°ÝÃD«á´N¶K¤W¨Ó¤F¦^ÂФF,
©Ò¥H§Úª¾¹D³o­Ó¬O¥u°w¹ïH6 ³o­ÓÀx¦s®æ,
§Úª¾¹DÁÙ­n¦b­×§ï,
©Ò¥Hª©¤j¤£¦n·N«ä°Õ,Åý±z»~·|¤F

TOP

        ÀR«ä¦Û¦b : ¥ÌÄ@°µ¡BÅw³ß¨ü¡C
ªð¦^¦Cªí ¤W¤@¥DÃD