Hello,
There are a few possibilities, including use of the Find Method, here's one
using Match()
Sub tester()
Dim myRng1 As Range, myRng2 As Range
Dim myArr As Variant
Let myArr = Sheets(1).Range("a1:iv1").Value
With WorksheetFunction
Set myRng1 = Sheets(1).Range("a1").Resize(, .Match(96, myArr, -1))
Set myRng2 = Range(Sheets(1).Cells(1, .Match(94, myArr, -1)), _
Sheets(1).Cells(1, .Match(91, myArr, -1)))
End With
Debug.Print myRng1.Parent.Name, myRng1.Address, _
myRng2.Parent.Name, myRng2.Address
Set myRng1 = Nothing: Set myRng2 = Nothing
End Sub
Be careful with cells < 95, if Match with a -1 can't find 94, it will jump
up to 95.
From the help file re: Match:
"If match_type is -1, MATCH finds the smallest value that is greater than or
equal to lookup_value. Lookup_array must be placed in descending order: TRUE,
FALSE, Z-A, ...2, 1, 0, -1, -2, ..., and so on. "
So you might want to test the return. You could specify an exact match with
0, and if it doesn't find your number, your procedure will error-out.
Regards,
Nate Oliver