0

I've been trying to run an array formula to return a variable.

On column B I have dates & times (mm/dd/yyyy hh:mm) and column C I have temperatures. I want to look for a value greater than or equal to 215 on the temperature column "C".

Dim TEMP215 As Variant
With Application.WorksheetFunction
TEMP215 = .Index(ActiveWorkbook.Sheets(1).Range("C2:C460"), .Match(True, ActiveWorkbook.Sheets(1).Range("C2:C460") >= 215, 0))
End With

If I write the formula just like that in a cell it works perfectly, running it with Ctrl + Shift + Enter. I have tried the TEMP215 as variant, long, integer, double, single... pretty much everything without success...

1 Answer 1

1

Try using the Evaluate method...

Dim TEMP215 As Variant

With ActiveWorkbook.Sheets(1).Range("C2:C460")
    TEMP215 = Evaluate("INDEX(" & .Address(External:=True) & ",MATCH(TRUE," & .Address(External:=True) & ">=215,0))")
End With

Note that the Evaluate method has a 255 character limit.

Sign up to request clarification or add additional context in comments.

3 Comments

How about when I have 2 different ranges? Now I want to find the value and return the time from column B With Application.WorksheetFunction TIME235 = .Index(ActiveWorkbook.Sheets(1).Range("$B$25:$B$" & LastRow), .Match(TEMP235, ActiveWorkbook.Sheets(1).Range("$" & TCColLet & "$25:$" & TCColLet & "$" & LastRow), 0)) End With
The previous one worked like charm BTW, thank you very much mate!
It looks like your lookup value for Match is incorrect. Shouldn't it be .Match(TEMP215, ...?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.