我对VBA很陌生,并且在我的Autofill系列方面遇到了一些问题 具体来说,我对这一行有疑问:
工作表("批次")。范围(" C2")。自动填充目的地:=工作表("批次")。范围(" C2 :C"& F)
我的完整代码如下,如果有人可以提供帮助,我们将不胜感激!
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Worksheets("Batches").Activate
Dim F As Long
lastRow = Worksheets("Batches").Range("A" & Rows.Count).End(xlDown).Row
Worksheets("Batches").Range("C2").AutoFill Destination:=Worksheets("Batches").Range("C2:C" & F)
Worksheets("Batches").Range("D2").AutoFill Destination:=Worksheets("Batches").Range("D2:D" & F)
Worksheets("Batches").Range("A:A").Copy
Worksheets("Batches").Range("G:G").PasteSpecial (xlPasteValues)
Worksheets("Batches").Range("D:D").Copy
Worksheets("Batches").Range("H:H").PasteSpecial (xlPasteValues)
Columns("G:H").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Batches").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Batches").Sort.SortFields.Add Key:=Range( _
"H2:H1048576"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Batches").Sort
.SetRange Columns("G:H")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True