# In column M how can I apply a 1 to the top 82 ranked values as defined in column L

In column M how can I apply a 1 to the top 82 ranked values as defined in column L
Example_LaborDistribution.xlsx
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi,

pls try
``````Sub macro()

For Idx = 1 To 82
Set Rng = Range(Range("L2"), Range("L" & Rows.Count).End(xlUp))
For Each c In Rng
If Idx1 < Idx And c.Offset(, 1) = "" And c = WorksheetFunction.Large(Rng, Idx) Then
c.Offset(, 1) = 1
Idx1 = Idx1 + 1
End If
Next
Next
End Sub
``````
Regards
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Excel & VBA ExpertCommented:
Maybe this...
In M2
``````=IF(L2>=LARGE(\$L\$2:\$L\$503,82),1,"")
``````
And then copy it down.
0
Commented:
@Neeraj The problem with the formula you get 90 values (8 more)
0
Commented:
then try
``````=IF(AND(SUM(\$M\$2:M62)<=83,L62>=LARGE(\$L\$2:\$L\$503,82)),1,"")
``````
Regards
0
Excel & VBA ExpertCommented:
@Rgonzo
Well in that case, the following formula will produce the output as same as produced by the code suggested by you.
In M2
``````=IF(ROWS(M\$2:M2)<=82,1,"")
``````
0
Commented:
@ neeraj in this example yes but the data is not sorted

then try corrected formula in M2
``````=IF(AND(SUM(\$M\$2:M2)<=82,L2>=LARGE(\$L\$2:\$L\$503,82)),1,"")
``````
and fill down

Regards
0
Thanks that worked.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.