標題:
[發問]
只想取部份字元
[打印本頁]
作者:
john2006168
時間:
2011-11-2 00:38
標題:
只想取部份字元
本帖最後由 john2006168 於 2011-11-2 00:40 編輯
[attach]8398[/attach][attach]8400[/attach][attach]8400[/attach][attach]8400[/attach]
作者:
Hsieh
時間:
2011-11-2 13:24
回復
1#
john2006168
如果是以斜線座分隔符號
資料剖析即可達到
作者:
john2006168
時間:
2011-11-2 15:57
回復
2#
Hsieh
可以 用"/" 請問用vba 怎麼寫.
作者:
GBKEE
時間:
2011-11-2 16:09
回復
3#
john2006168
Sub Ex()
Dim i As Integer, S As Integer
i = 2
With Sheet2
Do While .Cells(i, "A") <> ""
''''''Split 函數 ''''''''''''''''''''''''''''''''''''''''
'.Cells(i, "C") = Split(.Cells(i, "A"), "/")(1)
''''''InStr + MID 函數'''''''''''''''''''''''''''''''''
S = InStr(.Cells(i, "A"), "/")
.Cells(i, "C") = Mid(.Cells(i, "A"), S + 1)
i = i + 1
Loop
End With
End Sub
複製代碼
作者:
Hsieh
時間:
2011-11-2 17:44
回復
3#
john2006168
Range("A2:A4").TextToColumns _
DataType:=xlDelimited, Destination:=[C2], _
Other:=True, OtherChar:="/", FieldInfo:=Array(Array(1, 9), Array(2, 1))
作者:
john2006168
時間:
2011-11-2 18:06
回復 john2006168
GBKEE 發表於 2011-11-2 16:09
如果有些字沒有”/”,保持那些字不變,如下
A B C
JOHN/JOHN1234 JOHN1234
JOHN/JOHN1234 JOHN1234
JOHN
PETER [attach]8404[/attach]
作者:
Hsieh
時間:
2011-11-2 19:38
回復
6#
john2006168
For Each a In Range([A3], [A3].End(xlDown))
a.Offset(, 2) = Split(a, "/")(UBound(Split(a, "/")))
Next
作者:
GBKEE
時間:
2011-11-2 20:06
本帖最後由 GBKEE 於 2011-11-2 20:08 編輯
回復
6#
john2006168
Sub Ex()
Dim i As Integer, S As Integer
i = 2
With Sheet2
Do While .Cells(i, "A") <> ""
S = InStr(.Cells(i, "A"), "/")
If S > 0 Then
'.Cells(i, "C") = Split(.Cells(i, "A"), "/")(1)
.Cells(i, "C") = Mid(.Cells(i, "A"), S + 1)
.Cells(i, "A") = Left(.Cells(i, "A"), S - 1)
End If
i = i + 1
Loop
End With
End Sub
複製代碼
作者:
john2006168
時間:
2011-11-2 21:56
回復
8#
GBKEE
Thanks,這是我想要的answer
作者:
john2006168
時間:
2011-11-2 22:02
回復
7#
Hsieh
Thanks
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)