pdf导入表格到excel如何给数据分列
办公教程导读
收集整理了【pdf导入表格到excel如何给数据分列】办公软件教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1814字,纯文字阅读大概需要3分钟。
办公教程内容图文
可执行宏命令。
打开总表1.xlsm文件,执行宏ThisWorkbook.Macro2
代码如下:
Sub Macro2()
Dim fileDir As String '文本文件目录
Dim fileName As String '要打开的文本文件名
Dim serverNo As String
Dim serverDate As String
Dim dataSum As Long '要合并的文本记录数
Dim dataTotalOld As Long '汇总表中未合并时的记录条数
Application.ScreenUpdating = False
fileDir = ActiveWorkbook.Path & "\"
fileName = Dir(fileDir, 7)
Do While fileName <> "" And Right(fileName, 3) = "txt"
'fileName = "1 4-10.txt"
'获取服务器号和日期
serverNo = Left(fileName, InStr(1, fileName, " ") – 1) & "服"
serverDate = Mid(fileName, InStr(1, fileName, " ") + 1)
serverDate = Replace(serverDate, "-", "月")
serverDate = Replace(serverDate, ".txt", "日")
Workbooks.OpenText fileName:= _
ActiveWorkbook.Path + Application.PathSeparator & fileName, Origin:=936, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1)), TrailingMinusNumbers:=True
dataSum = Range("a65535").End(xlUp).Row
Range("A1:D" & dataSum).Select
Range("A1:D" & dataSum).Select
Selection.Copy
'总表1.xlsm为要合并后的启动宏工作表
Workbooks("总表1.xlsm").Activate
dataTotalOld = Range("a65535").End(xlUp).Row + 1
If dataTotalOld = 2 Then dataTotalOld = 1 '第一次使用
Range("C" & dataTotalOld).Select
ActiveSheet.Paste
Range("A" & dataTotalOld) = serverNo
Range("B" & dataTotalOld) = serverDate
Range("A" & dataTotalOld + 1) = serverNo
Range("B" & dataTotalOld + 1) = serverDate
Range("A" & dataTotalOld & ":B" & dataTotalOld + 1).Select
Selection.AutoFill Destination:=Range("A" & dataTotalOld & ":B" & dataTotalOld + dataSum – 1), Type:=xlFillDefault
Workbooks(fileName).Close savechanges:=False
fileName = Dir
Debug.Print fileName
Loop
Application.ScreenUpdating = True
End Sub
办公教程总结
以上是为您收集整理的【pdf导入表格到excel如何给数据分列】办公软件教程的全部内容,希望文章能够帮你了解办公软件教程pdf导入表格到excel如何给数据分列。
如果觉得办公软件教程内容还不错,欢迎将网站推荐给好友。