- Tham gia
- 5/6/08
- Bài viết
- 30,703
- Được thích
- 53,948
Cải tiến thêm 1 bước nữa, có lẽ nhanh hơn 1 chút do vòng lập For không quét hết chuổi (gặp Number thì Exit For ngay)
Xem file nha
PHP:
Option Explicit
Sub Tach()
Dim Rng As Range, Clls As Range
Dim i As Integer, K As Integer
Dim iText As String, Temp1 As String, Temp2 As String
Application.ScreenUpdating = False
[C1].CurrentRegion.ClearContents
[A1].CurrentRegion.Copy Destination:=[C1]
Set Rng = Range("C2:C" & [C1000].End(xlUp).Row)
Rng.TextToColumns Destination:=[C2], DataType:=xlDelimited, Other:=True, OtherChar:="|"
[C1].ClearContents
For Each Clls In [C2].CurrentRegion
For i = 1 To Len(Clls)
iText = Mid(Clls, i, 1)
If IsNumeric(iText) Then K = i: Exit For
Next i
With Clls
Temp1 = Left(.Value, K - 1): Temp2 = Right(.Value, Len(.Value) - K + 1)
.Value = Temp2: .NumberFormat = "0.00"
End With
Cells(1, Clls.Column) = Temp1
Next Clls
Application.ScreenUpdating = True
End Sub