|
用VBA来完成,代码不复杂——
- Option Explicit
- Sub 转换数据()
- Dim rng As Range, arr(9999, 3), i%
- Dim exp As Object, mc, m
- Set exp = CreateObject("VBScript.RegEXP")
- With exp
- .Global = True
- .ignorecase = True
- .Pattern = "[\u4e00-\u9fa5]+"
- End With
- arr(0, 0) = "驾驶员"
- arr(0, 1) = "出发日期"
- arr(0, 2) = "返程日期"
- arr(0, 3) = "送货员"
- For Each rng In Range("A2:A" & [A65536].End(xlUp).Row)
- i = i + 1
- arr(i, 0) = rng.Value
- arr(i, 1) = rng.Offset(0, 1).Value
- arr(i, 2) = rng.Offset(0, 2).Value
- If Len(rng.Offset(0, 3)) > 0 Then
- Set mc = exp.Execute(rng.Offset(0, 3).Value)
- For Each m In mc
- i = i + 1
- arr(i, 0) = m.Value
- Next
- End If
- Next
- Set exp = Nothing
- Set mc = Nothing
- [H:K].ClearContents
- [H1].Resize(UBound(arr), 4) = arr
- End Sub
复制代码
|
|