|
再给你个简单快速的方法- Private Sub CommandButton1_Click()
- Dim n As Integer, a As Integer, k As Integer, maxa As Integer, maxb As Integer, maxc As Integer
- Dim rga As Range, rgb As Range, rgc As Range, rg As Range
- Application.ScreenUpdating = False
- '清除原来的内容
- Range("BC5:BK107").ClearContents: Range("BM5:BU107").ClearContents: Range("BW5:CE107").ClearContents
- a = [r2]: k = 55
- '定义要取最大值的区域3个
- Set rga = Range("H107:Q107"): Set rgb = Range("U107:AD107"): Set rgc = Range("AH107:AQ107"): Set rg = Range("A1")
- 'On Error Resume Next
- '取多少列就循环多少次
- For n = 1 To a
- '计算第几大的位置
- maxa = Evaluate("=MATCH(LARGE( " & rga.Address & " *100+1/COLUMN( " & rga.Address & " )," & n & "), " & rga.Address & " *100+1/COLUMN( " & rga.Address & " ),0)") + 7
- maxb = Evaluate("=MATCH(LARGE( " & rgb.Address & " *100+1/COLUMN( " & rgb.Address & " )," & n & "), " & rgb.Address & " *100+1/COLUMN( " & rgb.Address & " ),0)") + 20
- maxc = Evaluate("=MATCH(LARGE( " & rgc.Address & " *100+1/COLUMN( " & rgc.Address & " )," & n & "), " & rgc.Address & " *100+1/COLUMN( " & rgc.Address & " ),0)") + 33
- '复制相应的列到相应的区域
- Range(Cells(5, maxa), Cells(107, maxa)).Copy
- Range(Cells(5, k), Cells(107, k)).PasteSpecial xlPasteFormulas
- Range(Cells(5, maxb), Cells(107, maxb)).Copy
- Range(Cells(5, (k + 10)), Cells(107, (k + 10))).PasteSpecial xlPasteFormulas
- Range(Cells(5, maxc), Cells(107, maxc)).Copy
- Range(Cells(5, (k + 20)), Cells(107, (k + 20))).PasteSpecial xlPasteFormulas
- k = k + 1
- Next
- [BD3].Activate
- On Error GoTo 0
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|