这要通过“复制---粘贴”的方法来实现。
打开其中的一个文件(这里暂定为文件1)。
2. 打开第二个文件(暂定为文件2),然后的 *** 作依次是:编辑---全选---复制。
3. 将刚才复制的内容粘贴到文件1当中。
4. 然后按照2、3两个步骤对文件3,4,5……等文件进行相同的 *** 作。
5. 最后将合并后的文件保存就可以了。当然,保存时可以给文件命名。
Private Sub CommandButton1_Click()
Dim qwjm As String
Dim wjm As String
ThisWorkbook.Sheets(1).Cells(1, 1) = "[名词]"
ThisWorkbook.Sheets(1).Cells(1, 2) = "[英文名称]"
ThisWorkbook.Sheets(1).Cells(1, 3) = "[注释]"
han = 1
aaa = ThisWorkbook.Name
myFileName = ThisWorkbook.Path & "\" & "*.txt"
wjm = Dir(myFileName)
If wjm <> "" Then
Do While wjm <> ""
han = han + 1
qwjm = ThisWorkbook.Path & "\" & wjm
Application.ScreenUpdating = False
Workbooks.Open qwjm
Set a1 = ActiveSheet.Cells.Find(what:="[名词]", LookIn:=xlValues)
Set a2 = ActiveSheet.Cells.Find(what:="[英文名称]", LookIn:=xlValues)
Set a3 = ActiveSheet.Cells.Find(what:="[注释]", LookIn:=xlValues)
If Not a1 Is Nothing Then
han1 = a1.Row
han2 = a2.Row
han3 = a3.Row
wb = ""
For x = han1 + 1 To han2 - 1
wb = wb & Sheets(1).Cells(x, 1) & Chr(10)
Next x
ThisWorkbook.Sheets(1).Cells(han, 1) = wb
wb = ""
For x = han2 + 1 To han3 - 1
wb = wb & Sheets(1).Cells(x, 1) & Chr(10)
Next x
ThisWorkbook.Sheets(1).Cells(han, 2) = wb
wb = ""
For x = han3 + 1 To Sheets(1).UsedRange.Rows.Count
wb = wb & Sheets(1).Cells(x, 1) & Chr(10)
Next x
ThisWorkbook.Sheets(1).Cells(han, 3) = wb
End If
Workbooks(wjm).Close
wjm = Dir
Loop
End If
End Sub
如图:
复制:(批处理文件,假设源文件夹为d:\m1,目标文件为d:\m2\test.txt)for /f "tokens=*" %%i in ('dir /b d:\m1\*.txt') do (
echo %%~ni>>d:\m2\test.txt
type d:\m1\%%i>>d:\m2\test.txt
echo. >>d:\m2\test.txt
echo. >>d:\m2\test.txt
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)