Link file test của em đây ạ :
Em có 1 đoạn code dưới đây :
Hình ảnh khi chạy test như sau :
Code hiện giờ em mới xử lý được đó là tách tên mã hàng thành từng cột.
Em muốn xử lý những số sau chữ "x" được tự động nhập hết sang số lượng hàng hóa.
Em muốn xử lý thành kết quả như hình dưới đây,mong mọi người giúp em.
Em xin chân thành cảm ơn sự giúp đỡ của mọi người
Bạn cần đăng nhập để thấy link
Em có 1 đoạn code dưới đây :
Mã:
Sub SplitAll()
Dim xRg As Range
Dim xRg1 As Range
Dim xCell As Range
Dim I As Long, j As Long, cnt As Long 'tuhocvba.net
Dim xAddress As String
Dim xUpdate As Boolean
Dim xRet As Variant
Range("A11:A40").ClearContents
Range("B11:B40").ClearContents
Dim s As String, kqtemp As String, gttemp As String 'tuhocvba.net
Const phantach As String = ",.-" 'tuhocvba.net
On Error Resume Next
xAddress = Application.ActiveWindow.RangeSelection.Address
Set xRg = ActiveWorkbook.ActiveSheet.Range("A3")
Set xRg1 = ActiveWorkbook.ActiveSheet.Range("A11")
If xRg Is Nothing Then Exit Sub
If xRg.Columns.Count > 1 Then
MsgBox "You can't select multiple columns", , "Hoc Excel Online"
Exit Sub
End If
' Set xRg1 = Application.InputBox("Chon Hang Cot Dich:", "Kutools for Excel", , , , , , 8) 'Khong can thiet vi da co dinh I6
' Set xRg1 = xRg1.Range("A1")
If xRg1 Is Nothing Then Exit Sub
xUpdate = Application.ScreenUpdating
Application.ScreenUpdating = False
For Each xCell In xRg
s = xCell.Value
cnt = -1
If s = "" Then
ReDim xRet(0 To 0)
xRet(0) = s
Else
kqtemp = ""
gttemp = ""
For j = 1 To Len(s) Step 1
kqtemp = Mid(s, j, 1)
If InStr(1, phantach, kqtemp, vbTextCompare) = 0 Then
If j = Len(s) Then
cnt = cnt + 1
If cnt = 0 Then
ReDim xRet(0 To cnt)
Else
ReDim Preserve xRet(0 To cnt)
End If
gttemp = gttemp & kqtemp
xRet(cnt) = gttemp
Exit For
End If
gttemp = gttemp & kqtemp
Else
cnt = cnt + 1
If cnt = 0 Then
ReDim xRet(0 To cnt)
Else
ReDim Preserve xRet(0 To cnt)
End If
xRet(cnt) = gttemp
gttemp = "" 'Reset
End If
Next j
End If
xRg1.Worksheet.Range(xRg1.Offset(I, 0), xRg1.Offset(I + UBound(xRet, 1), 0)) = Application.WorksheetFunction.Transpose(xRet)
I = I + UBound(xRet, 1) + 1
Next
Application.ScreenUpdating = xUpdate
End Sub
Bạn cần đăng nhập để thấy hình ảnh
Code hiện giờ em mới xử lý được đó là tách tên mã hàng thành từng cột.
Em muốn xử lý những số sau chữ "x" được tự động nhập hết sang số lượng hàng hóa.
Em muốn xử lý thành kết quả như hình dưới đây,mong mọi người giúp em.
Bạn cần đăng nhập để thấy hình ảnh
Em xin chân thành cảm ơn sự giúp đỡ của mọi người