PDA

View Full Version : Get the heights related data in row D



jadgon
08-01-2017, 02:53 PM
Compare score and get the heights related data in row D. Else in E.

mdmackillop
08-01-2017, 04:08 PM
You need to explain your results. I can't see any logic for this.

jadgon
08-01-2017, 04:33 PM
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.

mdmackillop
08-02-2017, 04:18 AM
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

jadgon
08-02-2017, 11:32 AM
Thanks a lot....And if I do not know the range ?

mdmackillop
08-02-2017, 11:48 AM
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.

SamT
08-02-2017, 11:49 AM
According to the original poster, the range is in Column "B"