|
コマンドボタンクリックイベント
Private Sub CommandButton1_Click()
Dim sr As String
If FindMin(sr) Then
CommandButton1.Caption = "Find Min Cell: " & sr
Else
CommandButton1.Caption = "Not Found"
End If
End Sub
'指定範囲から最小値を検索
Private Function FindMin(ByRef srow As String) As Boolean
Dim ans As Long
Dim tRange As Range
FindMin = False
'最小値を捜す
Set tRange = ActiveSheet.Range("D5:D100")
ans = Application.WorksheetFunction.Min(tRange)
'最小値のセルを取得
Set tRange = tRange.Find(What:=ans, LookIn:=xlValues, LookAt:=xlWhole)
If Not tRange Is Nothing Then
srow = tRange.Address
FindMin = True
End If
End Function
コマンドボタンクリックイベント
Private Sub CommandButton2_Click()
Dim sr As String
If FindMax(sr) Then
CommandButton2.Caption = "Find Max Cell: " & sr
Else
CommandButton2.Caption = "Not Found"
End If
End Sub
'指定範囲から最大値を検索
Private Function FindMax(ByRef srow As String) As Boolean
Dim ans As Long
Dim tRange As Range
FindMax = False
'最大値を捜す
Set tRange = ActiveSheet.Range("D5:D100")
ans = Application.WorksheetFunction.Max(tRange)
'最大値のセルを取得
Set tRange = tRange.Find(What:=ans, LookIn:=xlValues, LookAt:=xlWhole)
If Not tRange Is Nothing Then
srow = tRange.Address
FindMax = True
End If
End Function
|
|
|
|