Hi All,
I have a range in which I determine the maximum value in that range and it displays it in a MsgBox, the problem I am having is that I cannot figure out how to display the value in the the cell to the left of maximum value once the function completes. In my excel sheet Column D represents Time hence "T1", and Column E represents voltage "V1". In my code I realize I cannot use the cell location of my variable which is "maximum" for example
Range("maximum").Offset(0, -1).Select
although it's in my code for display purposes only. Can someone please point me in the right direction?
Sub FindMaxValue()
Dim rng As Range
Dim maximum As Double
'Set range from which to determine largest value
Set rng = Sheet1.Range("E1:E10000")
'Worksheet function MAX returns the largest value in a range
maximum = Application.WorksheetFunction.Max(rng)
'Displays largest value and it's offset value to the left
MsgBox "T1 Value: " & Range("maximum").Offset(0, -1).Select & vbNewLine & "V1 Value: " & maximum
End Sub
Bookmarks