- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
12#
發表於 2017-11-23 08:21
| 只看該作者
回復 11# papaya
參考看看,
不懂的VBA程式碼,可將不懂的函數,方法,在VBA說明上查看如 Application,或 Rows- Option Explicit
- Private Sub CommandButton1_Click()
- Dim Rng As Range, M As Integer
- Set Rng = Range("DK7", [DK7].End(xlDown))
- M = Application.Max(Rng)
- M = Application.Match(M, Rng, 0)
- [DT1] = Rng.Cells(M).Address(0, 0)
- With Rng.Resize(, 3)
- .Interior.ColorIndex = xlNone
- .Rows(M).Interior.ColorIndex = 8
- [dk4].Resize(, 3) = .Rows(M).Value
- End With
- End Sub
- Private Sub CommandButton2_Click()
- Dim Rng As Range, M As Integer
- Set Rng = Range("DK7", [DK7].End(xlDown)).Resize(, 3)
- For i = 1 To Rng.Columns.Count
- '*** 搜尋範圍內的每個欄位的最大值 ****
- With Rng.Columns(i)
- 'M = Application.Max(.Cells)
- M = Application.Match(Application.Max(.Cells), .Cells, 0)
- [DT1].Offset(i - 1) = .Cells(M).Address(0, 0)
- End With
- With Rng
- If i = 1 Then .Interior.ColorIndex = xlNone
- .Rows(M).Interior.ColorIndex = Array(, 8, 15, 22)(i)
- [dk4].Offset(i - 1).Resize(, 3) = .Rows(M).Value
- End With
- Next
- End Sub
複製代碼 |
|