|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 拆分()
- Dim arr, nRow&
- Dim pp '品牌
- nRow = Range("A" & Rows.Count).End(xlUp).Row
- arr = Range("A" & 2 & ":" & "A" & nRow)
- pp = Array("MOTO", "诺基亚", "三星", "索爱", "OPPO", "联想", "天语", "金立", "步步高", "波导", "TCL", "酷派")
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- Dim i&, j&
- For i = 1 To UBound(arr) Step 1
- If arr(i, 1) <> "" Then
- d(arr(i, 1)) = ""
- For j = 0 To UBound(pp) - 1 Step 1
- If arr(i, 1) Like "*" & pp(j) & "*" Then
- Select Case j
- Case 0, 1, 2, 3
- d(arr(i, 1)) = "进口"
- Case 4, 5, 6, 7, 8, 9, 10, 11
- d(arr(i, 1)) = "国产"
- Case Else
- d(arr(i, 1)) = ""
- End Select
- End If
- Next
- End If
- Next
- Dim t
- For Each t In d.keys
- Select Case d(t)
- Case "进口"
- Cells(Cells(Cells.Rows.Count, 3).End(xlUp).Row + 1, 3) = t
- Case "国产"
- Cells(Cells(Cells.Rows.Count, 4).End(xlUp).Row + 1, 4) = t
- Case ""
- Cells(Cells(Cells.Rows.Count, 5).End(xlUp).Row + 1, 5) = t
- End Select
- Next
- End Sub
复制代码
抱着学习的心态,做了习题4.向前辈致敬!
|
|