Consulting

Results 1 to 7 of 7

Thread: Get the heights related data in row D

  1. #1

    Get the heights related data in row D

    Compare score and get the heights related data in row D. Else in E.
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You need to explain your results. I can't see any logic for this.
    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
    find the top score in each cell and copy data in D. Others will go in E.
    In 2nd row i.e, in B2 "3.333" is the top score in group so top score related data i.e, D will go in D2 cell. All other data will go to E2.

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Please add location to your VBAX profile.

    Sub Test()
        For Each cel In Range("B2:B4")  'Adjust to suit
            Mx = 0: op1 = "": op2 = ""
            x = Split(cel, Chr(10))
            y = Split(cel.Offset(, 1), Chr(10))
            For i = 0 To UBound(x)
                If CDbl(x(i)) > Mx Then Mx = CDbl(x(i))
            Next
            For i = 0 To UBound(x)
                If CDbl(x(i)) = Mx Then
                    op1 = op1 & y(i) & ","
                Else
                    op2 = op2 & y(i) & ","
                End If
            Next
         cel.Offset(, 2) = Left(op1, Len(op1) - 1)
        cel.Offset(, 3) = Left(op2, Len(op2) - 1)
        Next
    End Sub
    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'

  5. #5
    Thanks a lot....And if I do not know the range ?

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    There are many ways to define a range depending upon your layout/requirements including Selection, finding LastRow, UsedRange, CurrentRegion, SpecialCells, Dynamic Range Names. You'll see a lot of examples in code here or search Google to find the most appropriate.
    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'

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    According to the original poster, the range is in Column "B"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

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