How to Display the Top Three Winners in a PowerPoint VBA Game
Question details
The user wants to display the top three winners (team names and scores) on a results slide in a custom PowerPoint VBA game.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Creating a custom PowerPoint Jeopardy or trivia game that requires dynamically sorting scores and outputting the top three teams to a winners slide.
- Observed behavior
- The user needs a programmatic method to sort team scores and their corresponding team names simultaneously, and then output those sorted values to specific text boxes.
Ensure that you have enabled the Developer tab in your presentation application and have basic familiarity with writing VBA macros. Remember to save your file as a Macro-Enabled Presentation to preserve your code.
Sort Team Scores and Names Using a VBA Macro
Use a VBA sorting algorithm to simultaneously arrange your score values and team names in descending order, then write the top three results to text boxes on your winners slide.
To achieve this, you need to store the team names and scores in parallel arrays. By sorting the scores using a standard loop (like a Bubble Sort), you can swap the corresponding team names at the exact same time. This keeps the data matched properly.
Press Alt + F11 to open the Visual Basic for Applications editor. Insert a new Module from the 'Insert' menu.
Declare two arrays: one for your team names (String) and one for their scores (Integer), ensuring they have enough elements for all teams (e.g., 1 To 6). Declare temporary variables to hold values during the swap.
Create a nested For loop to compare the scores. If a score at the current index is less than the score at the next index, swap their positions. Immediately swap the corresponding names in the exact same IF statement.
Reference the first-, second-, and third-place text boxes on your winners slide using VBA (e.g., ActivePresentation.Slides(x).Shapes("TextBox1").TextFrame.TextRange.Text). Assign the first three sorted names and scores to these text boxes.

Try WPS Office for Creating Interactive Presentations
While complex VBA macros are one way to build interactive games, WPS Presentation offers powerful built-in animation triggers and seamless Microsoft PowerPoint compatibility, making it easy to design highly engaging slides for free.
- 1. Download and Install: Download WPS Office Free from the official website and complete the lightweight installation.
- 2. Open Your Presentation: Launch WPS Presentation and open your existing PowerPoint game file to enjoy full compatibility.
- 3. Enhance with Triggers: Navigate to the Animation tab to add interactive triggers, eliminating the need for complex code in many trivia scenarios.

Frequently Asked Questions
Why are my PowerPoint VBA macros not running?
Your macros may be disabled by default for security reasons. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings, and choose 'Enable all macros'. Make sure your file is saved as a Macro-Enabled Presentation (.pptm).
Can I link a VBA variable directly to a shape on my slide?
Yes. You can dynamically update a shape's text using VBA. Use a line of code such as: ActivePresentation.Slides(1).Shapes("FirstPlace").TextFrame.TextRange.Text = Names(1) & " - " & Points(1).
What is the best way to handle ties in a VBA sorting loop?
After your array is fully sorted in descending order, run a secondary loop through the top three results. If the score at index (i) equals index (i+1), concatenate both team names into a single string for that rank before displaying it on the slide.




