Sub 一键复制()
Application.ScreenUpdating = False
Dim n, k, k1, pasths As Integer
Dim wb As Workbook
Dim rn As Range
With Sheet1
r = .Range("A65536").End(xlUp).Row
If r < 3 Then MsgBox "数据源为空!": End
ar = .Range("A4:I" & r)
End With
paths = ThisWorkbook.Path & "\"
f = Dir(paths & "台帐.xls*")
If f = "" Then MsgBox "找不到台账文件!": End
Set wb = Workbooks.Open(paths & f, 0)
With wb.Worksheets(1)
k = .Cells(Rows.Count, 3).End(xlUp).Row + 1
Set rn = .Range("b3:b" & k - 1).Find(Date, , , , , , 1)
If Not rn Is Nothing Then MsgBox "不能重复录入!": wb.Close False: End
.Cells(k, 3).Resize(UBound(ar), UBound(ar, 2)) = ar
.Cells(k, 1).Resize(UBound(ar), UBound(ar, 2) + 2).Borders.LineStyle = 1
For i = k To k + UBound(ar) - 1
.Cells(i, 1) = i - 2
.Cells(i, 2) = Date
Next i
End With
wb.Close True '保存并退出
Application.ScreenUpdating = True
MsgBox "导入完毕!", 64, "提醒"
End Sub
|