+ Reply to Thread
Results 1 to 5 of 5

Matching a value to a column, (rounding) and returning offset column value

Hybrid View

jayinthe813 Matching a value to a column,... 03-19-2013, 11:50 AM
Richard Buttrey Re: Matching a value to a... 03-19-2013, 12:28 PM
hafizimran Re: Matching a value to a... 03-19-2013, 12:37 PM
jayinthe813 Re: Matching a value to a... 03-19-2013, 01:50 PM
Richard Buttrey Re: Matching a value to a... 03-19-2013, 02:42 PM
  1. #1
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Matching a value to a column, (rounding) and returning offset column value

    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

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Matching a value to a column, (rounding) and returning offset column value

    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 icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1