How to create a scoring system using a macro?

tarekjamil

New Member
Joined
Sep 30, 2015
Messages
4
I would like to create a macro that adds or deducts points in a table based on the name of the player that was selected. The points are mentioned next to each criteria, meaning that the user selects the player from the dropdown menu and then clicks the add or deduct button. The macro then searches for the name of the player in the score table and then add/deducts the points accordingly.

CriteriaPointsPlayer Name
Speed10Bill Jellen
Strength20Tarek Jamil

<tbody>
</tbody>


PlayerPoints
Bill Jellen100
Tarek Jamil150

<tbody>
</tbody>
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I would like to create a macro that adds or deducts points in a table based on the name of the player that was selected. The points are mentioned next to each criteria, meaning that the user selects the player from the dropdown menu and then clicks the add or deduct button. The macro then searches for the name of the player in the score table and then add/deducts the points accordingly.

CriteriaPointsPlayer Name
Speed10Bill Jellen
Strength20Tarek Jamil

<tbody>
</tbody>


PlayerPoints
Bill Jellen100
Tarek Jamil150

<tbody>
</tbody>
Hi tarekjamil, welcome to the boards.

How big is the list of players? Is it a long list or a short one?
 
Upvote 0
The list of players is long around 50
Dang, I had been toying with a very inelegant solution based around a list of 5 or so players. The bigger the list of players got, the more cumbersome and horrible the code became. If there are approx 50 players on your list I will totally have to rethink my approach.

Hopefully someone cleverer than me will come along and help you in the meantime, otherwise it's back to the drawing board for me!
 
Upvote 0
Dang, I had been toying with a very inelegant solution based around a list of 5 or so players. The bigger the list of players got, the more cumbersome and horrible the code became. If there are approx 50 players on your list I will totally have to rethink my approach.

Hopefully someone cleverer than me will come along and help you in the meantime, otherwise it's back to the drawing board for me!

Hi Fishboy,
I don't think it should matter if you have 5 or 50 or 100 players. What you need to have is to have the following:
1) add or deduct buttons for each criteria
2) have a value in a table for each criteria (as shown in the post)
3) link the add/deduct button to the value of each criteria and to the cell which has the name of the player (whoever the player is)
4) the macro add/deducts the value (which is linked to the cell) and finds the name of the player (which is also linked to a cell) in a predefined table which has all the scores.
 
Upvote 0
Hi Fishboy,
I don't think it should matter if you have 5 or 50 or 100 players. What you need to have is to have the following:
1) add or deduct buttons for each criteria
2) have a value in a table for each criteria (as shown in the post)
3) link the add/deduct button to the value of each criteria and to the cell which has the name of the player (whoever the player is)
4) the macro add/deducts the value (which is linked to the cell) and finds the name of the player (which is also linked to a cell) in a predefined table which has all the scores.
Ok, so this still isn't quite how you want it yet, but I am making progress. As mentioned in a previous post I have had to rethink the way I have approached this and so far I have got a score table laid out as below:

Excel 2010
ABCD
1Score Up Macro ButtonScore Down Macro Button
2NameStrengthSpeedTotal Score
3John Lennon0
4Paul McCartney0
5George Harrison0
6Ringo Starr0
7Dave Dee0
8Dozy0
9Beaky0
10Mick0
11Titch0

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Scoring System



With the current set up, you simply put values into the score fields for Strength and / or Speed then click either the score up or score down button and the points are added or deducted from the players total at the end of the table. The code for these macros is as follows:

Score Up
Rich (BB code):
Sub Score_Up_All_Boxes()
    Dim rng As Range
    Dim i As Long
' Set the range in column B you want to loop through
    Set rng = Range(Cells(3, "B"), Cells(Rows.Count, "B").End(xlUp))
    For Each cell In rng
' test if cell is empty
        If cell.Value <> "" Then
' write to adjacent cell
            cell.Offset(0, 2).Value = cell.Offset(0, 2).Value + cell.Value
        End If
    Next
' Clears the contents of the newly processed scores
    Range(Cells(3, "B"), Cells(Rows.Count, "B").End(xlUp)).ClearContents
' Set the range in column C you want to loop through
    Set rng = Range(Cells(3, "C"), Cells(Rows.Count, "C").End(xlUp))
    For Each cell In rng
' test if cell is empty
        If cell.Value <> "" Then
' write to adjacent cell
            cell.Offset(0, 1).Value = cell.Offset(0, 1).Value + cell.Value
        End If
    Next
' Clears the contents of the newly processed scores
    Range(Cells(3, "C"), Cells(Rows.Count, "C").End(xlUp)).ClearContents
    MsgBox "Strength and Speed points added to total scores"
End Sub

Score Down
Rich (BB code):
Sub Score_Down_All_Boxes()
    Dim rng As Range
    Dim i As Long
' Set the range in column B you want to loop through
    Set rng = Range(Cells(3, "B"), Cells(Rows.Count, "B").End(xlUp))
    For Each cell In rng
' test if cell is empty
        If cell.Value <> "" Then
' write to adjacent cell
            cell.Offset(0, 2).Value = cell.Offset(0, 2).Value - cell.Value
        End If
    Next
' Clears the contents of the newly processed scores
    Range(Cells(3, "B"), Cells(Rows.Count, "B").End(xlUp)).ClearContents
' Set the range in column C you want to loop through
    Set rng = Range(Cells(3, "C"), Cells(Rows.Count, "C").End(xlUp))
    For Each cell In rng
' test if cell is empty
        If cell.Value <> "" Then
' write to adjacent cell
            cell.Offset(0, 1).Value = cell.Offset(0, 1).Value - cell.Value
        End If
    Next
' Clears the contents of the newly processed scores
    Range(Cells(3, "C"), Cells(Rows.Count, "C").End(xlUp)).ClearContents
    MsgBox "Strength and Speed points deducted from total scores"
End Sub


Eventually I want to work out a way to incorporate your selection of player from a drop-down list and have the score table separate as per your original request, but for the here and now this works. The problem is changing to a drop-down selection and separate score table will mean re-writing the macros. I just wanted to make sure I have the basic mechanics of it down before I start trying to make it more complicated.
 
Last edited:
Upvote 0
Hi Fishboy,

Thanks for the work, but there should be two things. 1) A predetermined list that has the points for each criteria (e.g. if I was doing the scoring for a students I would put 10 points for being early, 20 points for completing homework, etc.). So for each criteria I want to put a certain number of points in a table rather than hard-code the points (which I could change If I wanted to) 2) As you said, I want to be able to select the player for which I want to score up or score down.
The initial table in the post might be confusing. Here is a better depiction:
CriteriaPointsPlayer Name Dropdown
Homework Completion10Score Up Macro ButtonScroe Down Macro Button
Early20Score Up Macro ButtonScroe Down Macro Button
Respectful30Score Up Macro ButtonScroe Down Macro Button

<tbody>
</tbody>

<tbody>
</tbody>



NameHomework CompletionEarlyRespectfulTotal Score
John Lennon10101030
Paul McCartney20202060
George Harrison30303090
Ringo Starr10101030
Dave Dee20202060
Dozy30303090
Beaky10101030
Mick20202060
Titch30303090

<tbody>
</tbody>

kind regards,
 
Upvote 0

Forum statistics

Threads
1,216,774
Messages
6,132,649
Members
449,740
Latest member
Stevejhonsy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top