• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Associate a name to a given list

malek

New Member
Hello,

I need a VBA code that allow me to : from a given name and a mark associated to that name, if the name is already on the liste then add the mark to the mark that is already on the list and if not add that name and the mark to the list.

for example if I put Axel as a name and a 16 as mark. then if axel is not on the list then add the name and the mark to the list if it is on the liste then add the mark to the mark that is already there.

thank you for your help. You can find below the excel file to understand my ask better.
 

Attachments

  • fichier exemple.xlsx
    8.9 KB · Views: 4
Hello, according to your attachment an Excel basics VBA demonstration for starters :​
Code:
Sub Demo1()
        If [OR(B2="",B3="")] Then Beep: Exit Sub
    With [A17].CurrentRegion.Rows
            V = Application.Match([B2], .Columns(1), 0)
        If IsError(V) Then
            .Item(.Count)(2).HorizontalAlignment = xlCenter
            .Item(.Count)(2) = Array([B2], [B3])
        Else
            .Cells(V, 2) = [B3]
        End If
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Thank you Marc L for you answer but I want the code to add the new mark to the one on the list not replace it =)
 
In cells B2 and B3 we put the name and a mark.

If the name is not on the list so he put it on with the mark and if the name is already on the list so he add the mark we put in B3 to the mark that is already on the list.

With your vba code for example: if a put axel as name and 1 as a mark. Your code allow me to replace the mark 19 by 1. But I want a code.that add the new mark to the old one so here I want to obtain 20 (19+1) not 1.

I tried so hard to explain it hahaha I hope I did it well.
 
To sum both values just update the VBA demonstration with .Cells(V, 2) = [B3] + .Cells(V, 2) …​
 
Back
Top