+ Reply to Thread
Results 1 to 5 of 5

Help w/ Battleship Multimedia Project

Hybrid View

  1. #1
    Registered User
    Join Date
    11-13-2006
    Posts
    8

    Question Help w/ Battleship Multimedia Project

    Hey all. This seems like a great place to find some answers to my question. I am an Excel noob and have tried to use google to find what I need but it was to no avail. A friend and I are making a VERY simple version of Battleship for our multimedia class and need some help with functions/ VBA stuff. Could anyone give me a few pointers as to how I could accomplish the following?-

    1. The player has a 10x10 game board on sheet 1. When they click on a certain cell in sheet 1 on the game board (ex. B2), that particular cell turns white if the corresponding cell in sheet 2 ("B2" in the ex.) equals "0" and turns red if the corresponding cell in sheet 2 equals "1".

    This seems rather complicated and I cannot find a way to accomplish this. My teacher has no clue how to do it either but I would rather spend the time to accomplish this than do a half-*** project on a more generic topic, ie. football stats. Thank you very much in advance for any help you may be able to give and I hope that what I what to do is actually possible...

    -Pat

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening SSA_111

    Welcome to the forum!

    What's wrong with football stats?

    OK, two sheets, Sheet1 and Sheet2. the code below will check the corresponding cell of Sheet2 when you click on a cell in Sheet1. Won't do the whole project for you but it should give you a shove in the right direction.
    BTW, it's based on event procedures so you need to put it in the code module for Sheet1, not a regular module :

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Sheets("Sheet2").Range(ActiveCell.Address).Value = 1 Then
    ActiveCell.Interior.ColorIndex = 6
    End If
    End Sub
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    11-13-2006
    Posts
    8
    Thank you for your help! You mentioned that "BTW, it's based on event procedures so you need to put it in the code module for Sheet1, not a regular module :"- What would that be in layman's terms? The project will only require simple coding as the majority of the points will be awarded by using "the design process, etc" and not really based on thorough knowledge of Excel.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi

    OK. An event procedure is simply a procedure that occurs when a predifined event takes place. There is a double click event, ie we can fire a macro off when the user double clicks the mouse, but not a single click, so this code works around this by firing when the selection changes (ie when a different cell is clicked) - look at the first line of the macro, "Selection_Change"

    Where do you put it? Well, right click on the tab for Sheet1, select "View code" and copy the code into the big blank window that opens. Close the window and away you go.

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    11-13-2006
    Posts
    8
    Great! Thx a lot man, this should help out a ton.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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