Thanks to both of you! I could do either one but im automating with access and vba so the vba alternative makes more sense I think
Thanks to both of you! I could do either one but im automating with access and vba so the vba alternative makes more sense I think
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
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star iconbelow the post.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks