Dear Shweta
Please try the below macro..If you are new to macros Set the Security level
to low/medium in (Tools|Macro|Security). 'Launch VBE using short-key Alt+F11.
Insert a module and paste the below code. Save. Get back to
Workbook...Tools|Macro|Run Macro1(). I assume your data starts from Row2..
B vendor
C invoice value
D is quanti
E is avg formula
The below macro will assign the forumla for RANK. Please try and feedback
Sub Macro1()
Dim lngRow, lngStartRange, lngLastUpdated
lngStartRange = 2
For lngRow = 2 To ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row + 1
If Trim(Range("B" & lngRow)) = "" Or (Trim(Range("A" & lngRow)) <> "" _
And lngRow <> 2) Then
If lngLastUpdated <> lngStartRange Then
lngLastUpdated = lngStartRange
Range("F" & lngStartRange & ":F" & lngRow - 1).Formula = "=RANK(E" & _
lngStartRange & ",$E$" & lngStartRange & ":$E$" & lngRow - 1 & ",1)"
End If
End If
If Trim(Range("A" & lngRow)) <> "" Then lngStartRange = lngRow
Next
End Sub
If this post helps click Yes