Posts by pictoruta

    Currently self-learning VBA through WiseOwl and Googling. I’m trying to create Connect 4 in Excel, and have basically everything built except the win condition.

    Player 1’s “pieces” are marked by a “1” in the board, whereas Player 2’s are marked with a 0. I’m thinking of having a separate macro that gets called after a piece is dropped to check if a player has won the game.

    I’m unsure what’s the best way to create this macro to determine if there’s a win. Can anyone nudge me in the right direction?

    I’m thinking about having the macro sum four adjacent spaces. If the sum is 4, player 1 wins, if the sum is 0, player 2 wins, and for anything else, the game continues. Not sure how to implement this given the wide variety of positions on the board.