Consulting

Results 1 to 3 of 3

Thread: Solved: Function to Return Offsetted Values

  1. #1

    Solved: Function to Return Offsetted Values

    Hello I would like to write a function which takes in a range, finds the max of that range, and then returns all the values 3 columns to the left of the max as one string

    In the example the desired returned string is "a,b,c,e,h,j,l"

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Function ReturnComps(Data As Range)
    Dim cel As Range, Res As String
    For Each cel In Data
    If cel.Value = Application.Max(Data) Then
    Res = Res & cel.Offset(, -3) & ", "
    End If
    Next
    Res = Left(Res, Len(Res) - 2)
    ReturnComps = Res
    End Function
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thanks a lot mdmackillop!

Posting Permissions

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