|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 提取关键词()
- Dim arrA(), arrB(), arrC(), str$, key$, r%
-
- arrA = ArrayFromColumn("A")
- arrB = ArrayFromColumn("B")
- arrC = CloneSize(arrA)
- For r = 1 To UBound(arrA)
- str = arrA(r, 1)
- key = FindKeyword(str, arrB)
- arrC(r, 1) = key
- Next
-
- [C:C].ClearContents
- CellWriteArray [C1], arrC
- End Sub
- Function FindKeyword(str, keys()) As String
- Dim k
-
- For Each k In keys
- If InStr(1, str, k) > 0 Then
- FindKeyword = k
- Exit Function
- End If
- Next
- End Function
- Function ArrayFromColumn(col)
- Dim endRow As Long
- endRow = Cells(1, col).End(xlDown).Row
- ArrayFromColumn = Cells(1, col).Resize(endRow).Value2
- End Function
- Function CloneSize(arr())
- ReDim out(LBound(arr) To UBound(arr), LBound(arr, 2) To UBound(arr, 2))
- CloneSize = out
- End Function
- Sub CellWriteArray(cell As Range, arr())
- cell.Resize(UBound(arr), UBound(arr, 2)).Value2 = arr
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|