- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
2#
發表於 2014-11-21 17:08
| 只看該作者
回復 1# 蝕光迴狼
試試看- Option Explicit
- Private Sub CommandButton1_Click()
- Dim Rng(1 To 2) As Range
- Set Rng(1) = Range("c7", Range("c" & Rows.Count).End(xlUp))
- If Rng(1).Cells(1) = Range("c6") Then MsgBox "分數欄 沒有資料": Exit Sub
-
- With Range("A6").Resize(Rng(1).Rows.Count + 1, 7)
- .Interior.ColorIndex = xlNone
- .Sort Key1:=Range("C6"), Order1:=xlDescending, Header:=xlYes '自動排列大小(遞減排序)
- End With
- For Each E In Rng(1)
- 'A欄公式
- E.Cells(1, -1) = "=IF(RC[2]="""","""",LOOKUP(RC[2],{0,701,1301,1501,1701},{""B"",""A"",""S"",""S+"",""SS""}))"
- E.Cells(1, -1) = E.Cells(1, -1).Value
- 'B欄公式
- E.Cells(1, 0) = "=IF(RC[1]="""","""",RANK(RC[1],C[1]))"
- E.Cells(1, 0) = E.Cells(1, 0).Value
- Set Rng(2) = Range("H:H").Find(E.Cells(1, -1), LOOKAT:=xlWhole)
- E.Cells(1, -1).Interior.ColorIndex = Rng(2).Interior.ColorIndex
- E.Cells(1, 5).Interior.ColorIndex = Rng(2).Interior.ColorIndex
- Next
- End Sub
複製代碼 |
|