The code produces "9" which is in Y50. W50, what I am trying to find, is "3". Instead, it gives me the value of W39.
The 3rd question was what is the value of Y39.
And can you give me the result of the other code that I posted.
Set firstlocval = firstloc.Offset(0, -2)
MsgBox (firstlocval)
Sub test99()
MsgBox Evaluate("INDEX(W32:W57,MATCH(MAX(Y32:Y57),Y32:Y57,0))")
With WorksheetFunction
MsgBox .Index(Range("W32:W57"), .Match(.Max(Range("Y32:Y57")), Range("Y32:Y57"), 0))
End With
End Sub
The code in post number 10 shouldn't produce a 9 as that according to what you posted is in Y50. The code is offsetting by -2 columns and so should be giving a 3 from W50.
Do you have a 9 in column W, if yes what cell? and what is the value of column Y on the same row?Rich (BB code):Set firstlocval = firstloc.Offset(0, -2) MsgBox (firstlocval)
Sub eTest()
Dim first As Long
Dim firstlocval As Range
Dim firstloc As Range
first = CLng(WorksheetFunction.Max(Range("Y32:Y57")))
Set firstloc = Range("Y32:Y57").Find(first, , xlValues, xlWhole, xlByRows, xlNext, False)
Set firstlocval = firstloc.Offset(0, -2)
MsgBox (firstlocval)
End Sub
Out of interest does the below make a difference?
VBA Code:Sub eTest() Dim first As Long Dim firstlocval As Range Dim firstloc As Range first = CLng(WorksheetFunction.Max(Range("Y32:Y57"))) Set firstloc = Range("Y32:Y57").Find(first, , xlValues, xlWhole, xlByRows, xlNext, False) Set firstlocval = firstloc.Offset(0, -2) MsgBox (firstlocval) End Sub