小弟用錄製了巨集修改如下
Sub CC()
Set fd = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\" & "TT.txt"
With Workbooks.Open(FS).Sheets("TT")
FT.Sheets("Sheet2").Columns("A:B") = .Columns("A:B").Value
.Parent.Close False
End With
Application.ScreenUpdating = True
Set fd = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\TEST\" & "TT.txt"
With Workbooks.Open(FS).Sheets("TT")
FT.Sheets("Sheet2").Columns("G:H") = .Columns("A:B").Value
.Parent.Close False
End With
Application.ScreenUpdating = True
Set fd = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\" & "UU.csv"
With Workbooks.Open(FS).Sheets("UU")
FT.Sheets("Sheet2").Columns("C") = .Columns("A").Value
.Parent.Close False
End With
Application.ScreenUpdating = True
End Sub
Sub DD()
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\" & "TT.txt"
With Workbooks.Open(FS).Sheets("TT")
FT.Sheets("Sheet2").Columns("D:E").Copy .Columns("A:B")
.Parent.Close savechanges:=True
End With
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\TEST\" & "TT.txt"
With Workbooks.Open(FS).Sheets("TT")
FT.Sheets("Sheet2").Columns("G:H").Copy .Columns("A:B")
.Parent.Close savechanges:=True
End With
Application.ScreenUpdating = True
sheet2.[f1:f5] = [c1:c5].Value
Range("F6").Select
ActiveCell.FormulaR1C1 = "=""Count=""&COUNT(R[-5]C[-2]:RC[-2])"
Range("F7").Select
ActiveCell.FormulaR1C1 = "=""Lan""&R[-6]C[-2]&""=""&R[-6]C[-1]"
Range("F7").Select
Selection.Copy
Range("F8:F9").Select
ActiveSheet.Paste
Range("F6:F9").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.ScreenUpdating = False
Set FT = ActiveWorkbook
FS = "D:\TEST\TEST20\" & "UU.csv"
With Workbooks.Open(FS).Sheets("UU")
FT.Sheets("Sheet2").Columns("F").Copy .Columns("A")
.Parent.Close savechanges:=True
End With
Application.ScreenUpdating = True
End Sub