Hi,
Do either of these help. One is a function, so enter say
=Percentage(3150)
in a cell.
The other is an equivalent procedure which will result in the dResult value showing the percentage.
Function Percentage(lmyvalue As Long) As Variant
Dim lRow As Long
If lmyvalue > 3500 And lmyvalue < 15000 Then
lRow = WorksheetFunction.Match(lmyvalue, Range("A:A"), 1)
Percentage = Application.WorksheetFunction.Index(Range("B:B"), lRow, 1)
Else
Percentage = "Outside limits"
End If
End Function
Sub GetPercentage()
Dim lRow As Long, lmyvalue As Long, dResult As Variant
lmyvalue = 3150 ' or use an input box to get a value
If lmyvalue > 3500 And lmyvalue < 15000 Then
lRow = WorksheetFunction.Match(lmyvalue, Range("A:A"), 1) + 1
dResult = Format(Application.WorksheetFunction.Index(Range("B:B"), lRow, 1), "0.000")
Else
dResult = "Outside limits"
End If
End Sub
Bookmarks