Results 1 to 5 of 5

Multiple variables, loops, & code optimisation

Threaded View

  1. #1
    Registered User
    Join Date
    06-28-2014
    Location
    manchester, england
    MS-Off Ver
    home and student 2010
    Posts
    3

    Multiple variables, loops, & code optimisation

    Hi, I’m working on a spreadsheet which contains the results of 7000+ online 8 ball/9 ball pool matches. I thought that since many of the players have played each other multiple times it would be fun to produce some head-to-head statistics, showing who has won how many matches against whom.

    So far I’ve written a macro which searches the 7000 entries for a player name (called PlayerA in the spreadsheet). This prompts for a player name using an Input box and copies all the matches from the MatchData sheet into the Query sheet – which is basically a list of results. When this is done, it will look like something below:

    http://i1284.photobucket.com/albums/...ps8by3v4by.jpg

    In cell C10, the player I searched for, “rowunbeat”, is named, and the number of matches is displayed below this in C11.

    What I need help with is how to compare the scores in columns F and G to find the highest, link them to the player name, and fill out cells C12:C15 and I12:I15. It looks like the code could become complicated, and I’d have to assign variables to the five main columns, called Player1, Score1, Score2, Player2, and Decider, as well as the player names in C10 and I10. Then check whether Score1 was greater than, equal to, or less than Score2; then check whether the textstring Player1 or Player2 matches PlayerA (the name in C10), then add 1 to the appropriate cell below their name depending on whether they won, lost or drew the match. I would also need a variable for looping down the rows, to keep track of which row entry I’m up to. This sounds very messy to me, since it looks like it will require multiple Ifs and Loops within each other, and I’m looking for a clue where to start, or whether there’s an easier way of doing this. This is my first attempt at coding in vba since 1999, and this probably shows in the existing code …

    *Additional info*: 1. The ‘deciding frame win’ column (column I) is meant to be counted in either C15 or I15, depending on which player has the highest score. As long as these totals are kept distinct, it will be easy to calculate this as a percentage later. The other additional columns (tournament name, type, WT, and Round) are only extra information.
    2. Eventually I hope to add a second search to this page which allows PlayerA to be compared to a specific second player (at the moment they are compared to Everyone Else). I think this should be easy enough for me to work out if I can get the code sorted out above, since it would use variations of the initial search I’ve already done.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Code Optimisation - Run Speed
    By swizard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2013, 10:22 AM
  2. Loops using multiple variables
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2011, 06:08 AM
  3. Optimisation of code
    By munkee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2009, 10:26 AM
  4. Loops with Variables
    By AccountantCost in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2009, 10:02 PM
  5. Help please! Loops? For Each? Variables?
    By Roger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2005, 09:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1