|
楼主 |
发表于 2022-5-12 11:18
|
显示全部楼层
- Sub AutoSave()
- Application.ScreenUpdating = False
- Application.OnTime Now() + TimeValue("00:03:00"), "WbSave" 'N分钟保存一次
- Application.ScreenUpdating = True
- End Sub
- Sub WbSave()
- Dim last As Integer
- Dim WBK, Wb As Excel.Workbook
- Dim Sh As Excel.Worksheet
- Set WBK = Application.ActiveWorkbook
- Set Sh = WBK.Sheets("sheet1")
-
- last = Sh.Range("C65536").End(xlUp).Row 'Range("B65536").End(xlUp).Row - 2 '导入
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
-
-
- Set Wb = Workbooks.Add(xlWBATWorksheet)
- With Wb '添加新工作簿
- .Worksheets(1).Name = "Sheet1" '工作表改名
- ' Sh.Cells.Copy .Worksheets(1).Cells '复制单元格
- Sh.Range("A1:G" & last).Copy .Worksheets(1).Range("A1:G" & last)
- .SaveAs Filename:="D:\DHRP\EXCEL\test66.xlsx", FileFormat:=51 '
- .Close False
- End With
- Call AutoSave
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- End Sub
复制代码
谢谢。我接凑了一个,好像也成功了
|
|