Try this
Sub StuffToDo()
Dim Rws As Long, Rng As Range, c As Range
Dim Rnk As Range, y As Range, Srk As Range
Rws = Cells(Rows.Count, "B").End(xlUp).Row
Set Rng = Range(Cells(1, 2), Cells(Rws, 2))
For Each c In Rng.Cells
On Error Resume Next
If c = "Data" Or c = "MS" Then
Set y = Range(c.Offset(1, 0), c.End(xlDown))
Set Rnk = Range(c.Offset(1, 1), c.Offset(1, 1).End(xlDown))
For Each Srk In Rnk.Cells
If Srk.Offset(0, -1) <> "" Then
Srk = WorksheetFunction.Rank(Srk.Offset(0, -1), y)
End If
Next Srk
End If
Next c
End Sub
Bookmarks