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

[µo°Ý] ¦³Ãö¸ê®Æ­åªR

[µo°Ý] ¦³Ãö¸ê®Æ­åªR

·Q­n±ÐColumn A(¾ãÄæ¦ì)ªº¸ê®Æ¤À³Î¨ìB/C/D Äæ¦ì
AÄæ¦ì¸ê®Æ¤º®e¬°¤é´Á®æ¦¡ ¨Ï¥ÎVB¼gªº¸ÜÀ³¸Ó«ç»ò¼g?¤À³Î¨Ì¾Ú¬°"/" ¦ý¬O¨Sªk¶¶§Q¤Á³Î¶}
¤£ª¾¹D§Ú¼gªº¬O§_¥¿½T·Q½Ð±ÐªO¤W±M®a

Sub AA()
Range("A:A").TextToColumns Destination:=Range("B"), OtherChar _
        :="/"

End Sub

¦^´_ 11# GBKEE


    ÁÂÁª©¥D¸ÑÄÀ
   ¦n¹³ÁÙ­nªáÂI®É¶¡²z¸Ñ
  ¥ý¦¬¤U¨ÓºCºC«~À|¤@¤U
¦r¨å¨â¦U¦r ÁÙ¯uÃø²z¸Ñ

TOP

¦^´_ 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¼Æªí¥Üªº°Ï°ì¦ì²¾ (¥¿­È¡B­t¼Æ©Î¹s (0))¡C¥¿­Èªí¥Ü¦V¤U¦ì²¾¡A­t­Èªí¥Ü¦V¤W¦ì²¾¡C¹w³]­È¬° 0¡C
ColumnOffset      ¿ï¾Ü©Êªº Variant¡C¥ÎÄæ¼Æªí¥Üªº°Ï°ì¦ì²¾ (¾ã¼Æ¡B­t¼Æ©Î 0 (¹s))¡C¥¿­Èªí¥Ü¥k¦ì²¾¡A­t­Èªí¥Ü¥ª¡C¹w³]­È¬° 0¡C
  1. Option Explicit
  2. Sub Ex()  '±N¦r¦ê¤À³Î¦¨¤l¦r¦ê
  3.     Dim A As Range
  4.     'SpecialCells ¤èªk ¦¹ª«¥ó¥Nªí»P«ü©w«¬ºA¤Î­È¬Û²Å¦Xªº©Ò¦³Àx¦s®æ¡CRange ª«¥ó¡C
  5.     For Each A In Range("A:A").SpecialCells(xlCellTypeConstants) 'xlCellTypeConstants¡C¥]§t±`¼ÆªºÀx¦s®æ
  6.         'If IsDate(A) Then     '¬O¤é´Á«¬ºA
  7.         If InStr(A, "/") Then  '¦r¦ê¤¤¦³ "/"
  8.         'InStr ¨ç¼Æ ¶Ç¦^¦b¬Y¦r¦ê¤¤¤@¦r¦êªº³Ì¥ý¥X²{¦ì¸m¡A¦¹¦ì¸m¬° Variant (Long)¡C
  9.             With A.Offset(, 1).Resize(, 3)
  10.             '¥HA.Offset(, 1):[BÄæ],Resize(, 3):ÂX¥R3Ä檺Range½d³ò
  11.                 .Value = Split(A, "/")   '¥H "/" ¤À³Î¦r¦ê
  12.                 .Value = .Value          'Åܧ󬰼Ʀr
  13.             End With
  14.            'Split ¨ç¼Æ ¶Ç¦^¤@­Ó³¯¦C¯Á¤Þ±q¹s¶}©lªº¤@ºû°}¦C , ¥¦¥]§t«ü©w¼Æ¥Øªº¤l¦r¦ê
  15.         End If
  16.     Next
  17. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# hugh0620

¡@ ¤j¤j¤U­±¨âªº¥i¥H¸ÑÄÀ¤@¤U¶Ü
    vbDatabaseCompare  &¡@columnoffset
    ¤£¤Ó¾å±o¥Îªk
¦r¨å¨â¦U¦r ÁÙ¯uÃø²z¸Ñ

TOP

°ÝÃD¦n¹³¸Ñ¶}¤F...­ì¥»§Ú¦³¥|­Ó¤é´ÁÄæ¦ì»Ý­n¸ê®Æ­åªR­ì¥»¿ý»sªº¤è¦¡¬O¤@¦¸¥þ³¡°µ§¹
¦ý¬O¦n¹³·|¦³¿ù¶Ãªº²{¶H(°õ¦æ¨ì¤@¥b¥d¦í©Î¬O«á­±ªº´¡¤JÄæ¦ì¿ù¦ì)§Úªº¨BÆJ¦p¤U
¦b¨C­Ó¤é´ÁÄæ¦ì«á­±´¡¤J¤­­ÓªÅ¥ÕÄæ¦ì¸ê®Æ­åªR«á§R°£³Ì«á¨â­Ó¹w¯dÄæ¦ì.¥H¤W¨BÆJ­«ÂÐ¥|¦¸
«á¨Ó§Ú¤À¥|¦¸¿ý»s¦b¦ê±µ°_¨Ó¨S¦³¿ù»~µo¥Í.anyway ·PÁªO¤W°ª¤â¨ó§U

TOP

¥»©«³Ì«á¥Ñ mark15jill ©ó 2012-3-27 15:49 ½s¿è

¦^´_ 7# tommy.lin


    ³Â·Ð¶K¹Ï ¬Ý­þÃ䦳¿ù..



Sub xyw()
Columns("g:g").Select
    Selection.TextToColumns Destination:=Range("m1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(3, 2), Array(2, 2), Array(1, 2)), _
        TrailingMinusNumbers:=True
        
    sy = Columns("o:o").Value
    Columns("t:t") = sy
    sm = Columns("n:n").Value
    Columns("u:u") = sm
    sd = Columns("m:m").Value
    Columns("v:v") = sd
    Columns("m:o").Clear
End Sub

TOP

§Ú¦³¸ÕµÛ¥Î¥¨¶°¿ý»s¦¨¤W­±³o¼Ë¤l¦ý¹ê»Ú°õ¦æ®É·|¥X²{error....

TOP

¥»©«³Ì«á¥Ñ mark15jill ©ó 2012-3-27 13:36 ½s¿è

¦^´_ 5# tommy.lin
ª½±µ§âµ{¦¡¥á¶iVBA¤º..



sub xxg
        Columns("a:a").Select
    Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2)), _
        TrailingMinusNumbers:=True
end sub

§@¥Î¡G¥Î / ¬°§PÂ_²Å¸¹ ¥[¥H¤Á³Î

TOP

¥i¥H¤F...Thanks lots..¤£¹L¬Ý¤£À´»yªk

TOP

¥»©«³Ì«á¥Ñ hugh0620 ©ó 2012-3-27 12:17 ½s¿è

¦^´_ 3# tommy.lin

BÄæ¦ì~ ½Ð§ï¦¨¼Æ­È®æ¦¡~
ÃD¨Ñ¨âºØ¤è¦¡µ¹§A°Ñ¦Ò~
  1. Sub EX_1()
  2. For Each a In Range("A2:A65536")
  3.     If a <> "" Then
  4.        a.Offset(0, 1) = Year(a)
  5.        a.Offset(0, 2) = Month(a)
  6.        a.Offset(0, 3) = Day(a)
  7.     End If
  8. Next
  9. End Sub
½Æ»s¥N½X
  1. Sub xx()  '±N¦r¦ê¤À³Î¦¨¤l¦r¦ê
  2. For Each a In Range("A:A")
  3. h = Split(a, "/", 3, vbDatabaseCompare)
  4.     i = 1
  5.     For Each b In h
  6.     a.Offset(columnoffset:=i) = b
  7.     i = i + 1
  8.     Next
  9. Next
  10. End Sub
½Æ»s¥N½X
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

        ÀR«ä¦Û¦b : ¬O«D·í±Ð¨|¡AÆg¬ü§@ĵ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD