常用VBA 命令
作者:互联网
单元格区域复制,后关闭表格
Sub QS1DataCopy() Dim c As Range 'copy the downloaded excel to target excel With ActiveWorkbook.Worksheets(1) maxRow = .Cells(100, 1).End(xlUp).Row maxRow2 = Workbooks("customer claim order.xlsx").Worksheets("status").Cells(1048576, 1).End(xlUp).Row .Range(.Cells(2, 3), .Cells(maxRow, 9)).Copy Workbooks("customer claim order.xlsx").Worksheets("status").Cells(maxRow2 + 1, 1) End With With Workbooks("customer claim order.xlsx").Worksheets("Order") ' Set c = .Range(.Cells(2, 1), .Cells(1000, 1)).Find(Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2, 8)) ' If Not c Is Nothing Then ' Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Range(Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2 + 1, 8), Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2 + maxRow - 1, 8)) = .Cells(c.Row + 1, 1) ' End If Call closeworkbook End With Workbooks("customer claim order.xlsx").Activate Workbooks("customer claim order.xlsx").Worksheets("status").Cells(maxRow2 + maxRow - 1, 8).Select End Sub Sub closeworkbook() Dim wb As Workbook For Each wb In Workbooks If wb.Name <> "customer claim order.xlsx" And wb.Name <> "PERSONAL.xlsm" Then wb.Close savechanges:=False End If Next End Sub
Sub QS1DataCopy() Dim c As Range 'copy the downloaded excel to target excel With ActiveWorkbook.Worksheets(1) maxRow = .Cells(100, 1).End(xlUp).Row maxRow2 = Workbooks("customer claim order.xlsx").Worksheets("status").Cells(1048576, 1).End(xlUp).Row .Range(.Cells(2, 3), .Cells(maxRow, 9)).Copy Workbooks("customer claim order.xlsx").Worksheets("status").Cells(maxRow2 + 1, 1) End With With Workbooks("customer claim order.xlsx").Worksheets("Order") ' Set c = .Range(.Cells(2, 1), .Cells(1000, 1)).Find(Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2, 8)) ' If Not c Is Nothing Then ' Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Range(Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2 + 1, 8), Workbooks("customer claim order.xlsx").Worksheets("Sheet1").Cells(maxRow2 + maxRow - 1, 8)) = .Cells(c.Row + 1, 1) ' End If Call closeworkbook End With Workbooks("customer claim order.xlsx").Activate Workbooks("customer claim order.xlsx").Worksheets("status").Cells(maxRow2 + maxRow - 1, 8).Select End Sub Sub closeworkbook() Dim wb As Workbook For Each wb In Workbooks If wb.Name <> "customer claim order.xlsx" And wb.Name <> "PERSONAL.xlsm" Then wb.Close savechanges:=False End If Next End Sub
标签:customer,xlsx,VBA,claim,Cells,常用,order,命令,Workbooks 来源: https://www.cnblogs.com/sundanceS/p/12530974.html