|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
ChDrive Left(ThisWorkbook.FullName, 1) '点击导入按钮,指向当前盘
ChDir ThisWorkbook.Path '指向当前路径
f = Application.GetOpenFilename("Microsoft Office word 文件 (*.doc*),*.doc*", , "请选择要导入的数据:") '打开对话框,选择一个文件f
If f = False Then
MsgBox "本次没有选择任何文件!"
Exit Sub
End If
Set wdapp = CreateObject("word.application")
Set wb = wdapp.Documents.Open(f)
arr = Split(wb.Range, Chr(13))
wb.Close
brr = Sheets(2).[a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For j = 2 To UBound(brr, 2)
d(brr(1, j)) = j
Next
For Each k In arr
If InStr(k, ":") > 0 Then
crr = Split(WorksheetFunction.Clean(k), ":")
s = WorksheetFunction.Clean(crr(0))
If d.exists(s) Then brr(1, d(s)) = crr(1)
End If
Next k
brr(1, 1) = UBound(brr)
Sheets(2).Cells(UBound(brr) + 1, 1).Resize(1, UBound(brr, 2)) = brr
End Sub
|
评分
-
1
查看全部评分
-
|