Add a Value for first value in Column

I need a macro that would assign a 1 to the first value and a 0 to each additional value that is the same. IE

Apple  1
Apple  0
Apple  0
Orange 1
Banana 1
kiwi 1
Banana 0

Searching Column E and Put the value in Column N start at row 2.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Rob HensonFinance AnalystCommented:
No need for VBA


Copied down as far as required.

Rob H
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:

If I am not wrong, tt should be like this.....


Open in new window

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
If you really need a VBA solution, you may try this.....
Sub Put1ForUniqueItems()
Dim lr As Long
Dim Rng As Range, Cell As Range, chkRng As Range

lr = Cells(Rows.Count, "E").End(xlUp).Row
Set Rng = Range("E2:E" & lr)

For Each Cell In Rng
    Set chkRng = Range(Cells(2, "E"), Cells(Cell.Row, "E"))
    If WorksheetFunction.CountIf(chkRng, Cell) = 1 Then
        Cells(Cell.Row, "N") = 1
        Cells(Cell.Row, "N") = 0
    End If
Next Cell
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

montrofAuthor Commented:
This is perfect Thank you so much!!
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad it worked as per your requirement. :)
Rob HensonFinance AnalystCommented:
Sktneer - correct, I omitted to offset by a row to count the cells above.
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 Excel

From novice to tech pro — start learning today.