|
6#
楼主 |
发表于 2016-5-17 09:12:15
|
只看该作者
经过几天尝试,写了一组代码,请各位老师看看,参考附- Public j, i
- Private Sub 刷新_Click()
- Range("A1:M1").Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorDark1
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With '将数值区填充恢复无色
- For x = 1 To 13
- Cells(1, x) = Application.WorksheetFunction.RandBetween(1, 100)
- Next
- End Sub
- Private Sub 显示3个最大值_Click()
- j = 0
- i = 0
- arr = Range(Cells(1, 1), Cells(1, 13))
- A = Application.WorksheetFunction.Large(arr, 1) 'A B C 为每行最大三个
- B = Application.WorksheetFunction.Large(arr, 2)
- C = Application.WorksheetFunction.Large(arr, 3)
- If A > B Then
- Call XH(A)
- Call XH(B)
- If B > C Then
- Call XH(C)
- End If
- Else
- Call XH(A)
- If B > C Then
- Call XH(C)
- End If
- End If
- End Sub
- Sub XH(A) '最大三个数值填充红色
- For y = 1 To 13
- If j < 3 Then
- If Cells(1, y) = A Then
- Cells(1, y).Select
- With Selection.Interior
- .Pattern = xlSolid
- .PatternColorIndex = xlAutomatic
- .Color = 255
- .TintAndShade = 0
- .PatternTintAndShade = 0
- End With
- j = j + 1
- End If
- End If
- Next
- End Sub
复制代码 件 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|