- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 10# freeffly
VBA ªº»¡©ú
Split ¨ç¼Æ ¶Ç¦^¤@Ó³¯¦C¯Á¤Þ±q¹s¶}©lªº¤@ºû°}¦C¡A¥¦¥]§t«ü©w¼Æ¥Øªº¤l¦r¦ê¡C
»yªk
Split(expression[, delimiter[, limit[, compare]]])
Split ¨ç¼Æ»yªk¦³¦p¤U´XÓ«ü¦W¤Þ¼Æ¡G ½Ð¬d¬ÝVBA ªº»¡©ú
Offset ÄÝ©Ê ¶Ç¦^ Range ª«¥ó¡A¥Î¥H¥Nªí¬YÓ«ü©w°Ï°ì¥H¥~ªº½d³ò¡C°ßŪ¡C
expression.Offset(RowOffset, ColumnOffset)
expression ¥²¿ï¡C¸Ó¹Bºâ¦¡¶Ç¦^ Range ª«¥ó¡C
RowOffset ¿ï¾Ü©Êªº Variant¡C¥Î¦C¼Æªí¥Üªº°Ï°ì¦ì²¾ (¥¿È¡Bt¼Æ©Î¹s (0))¡C¥¿Èªí¥Ü¦V¤U¦ì²¾¡AtȪí¥Ü¦V¤W¦ì²¾¡C¹w³]Ȭ° 0¡C
ColumnOffset ¿ï¾Ü©Êªº Variant¡C¥ÎÄæ¼Æªí¥Üªº°Ï°ì¦ì²¾ (¾ã¼Æ¡Bt¼Æ©Î 0 (¹s))¡C¥¿Èªí¥Ü¥k¦ì²¾¡AtȪí¥Ü¥ª¡C¹w³]Ȭ° 0¡C- Option Explicit
- Sub Ex() '±N¦r¦ê¤À³Î¦¨¤l¦r¦ê
- Dim A As Range
- 'SpecialCells ¤èªk ¦¹ª«¥ó¥Nªí»P«ü©w«¬ºA¤ÎȬ۲ŦXªº©Ò¦³Àx¦s®æ¡CRange ª«¥ó¡C
- For Each A In Range("A:A").SpecialCells(xlCellTypeConstants) 'xlCellTypeConstants¡C¥]§t±`¼ÆªºÀx¦s®æ
- 'If IsDate(A) Then '¬O¤é´Á«¬ºA
- If InStr(A, "/") Then '¦r¦ê¤¤¦³ "/"
- 'InStr ¨ç¼Æ ¶Ç¦^¦b¬Y¦r¦ê¤¤¤@¦r¦êªº³Ì¥ý¥X²{¦ì¸m¡A¦¹¦ì¸m¬° Variant (Long)¡C
- With A.Offset(, 1).Resize(, 3)
- '¥HA.Offset(, 1):[BÄæ],Resize(, 3):ÂX¥R3Ä檺Range½d³ò
- .Value = Split(A, "/") '¥H "/" ¤À³Î¦r¦ê
- .Value = .Value 'Åܧ󬰼Ʀr
- End With
- 'Split ¨ç¼Æ ¶Ç¦^¤@Ó³¯¦C¯Á¤Þ±q¹s¶}©lªº¤@ºû°}¦C , ¥¦¥]§t«ü©w¼Æ¥Øªº¤l¦r¦ê
- End If
- Next
- End Sub
½Æ»s¥N½X |
|