我录一个宏挑的前十名最大的行业排序第一十个购买然后十销售。根据D列排序数据后,它复制交易信息并将其粘贴到另一个单元格中。
然后它按E列,以获得最大的销售,并复制相同的数据范围到另一个细胞糊。
的问题是,它会复制错误的信息,因为它不能在同一时间被列d和E的数据进行排序。我如何让宏复制并粘贴正确的信息?宏观变化的数据覆盖以前的数据
Sub ttt()
'
' ttt Macro
' top ten trades output
'
' Keyboard Shortcut: Ctrl+Shift+T
' buys
Rows("3:3").Select
Selection.AutoFilter
ActiveSheet.AutoFilter.Sort.SortFields.Add Key:=Range("D3" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortTextAsNumbers
With ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A5:I14").Select
Selection.Copy
Range("K3").Select
ActiveSheet.paste
Application.CutCopyMode = False
' sells
ActiveSheet.AutoFilter.Sort.SortFields.Add Key:=Range("E3" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortTextAsNumbers
With ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A5:I14").Select
Selection.Copy
Range("u3").Select
ActiveSheet.paste
Application.CutCopyMode = False
End Sub
此使用“清除”命令工作。谢谢你的帮助 –