|
Sub CopyToFile()
Dim WB1 As Workbook, WB2 As Workbook
Application.ScreenUpdating = False
Set WB1 = Application.Workbooks.Open(ThisWorkbook.Path & "\发货明细.xlsx")
Set WB2 = Application.Workbooks.Open(ThisWorkbook.Path & "\发货明细及对账单.xlsx")
WB1.ActiveSheet.Range("C2:E5000,G2:H5000,R2:S5000,U2:U5000").Copy WB2.Sheets(1).Range("C2:J5000")
WB1.Close True
WB2.SaveAs Filename:=ThisWorkbook.Path & "\对账单\" & _
Format(Date, "mm月dd号") & "发货明细及对账单.xlsx"
WB2.Close True
Application.ScreenUpdating = True
End Sub
在2019中可以自动运行,在office 2021中打开宏表格就卡死,无法执行。换了好几个版本的2021了,均不行。。。求大神给优化下代码。主要是想更新2021用unique公式,提取不同值 |
|