1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Spreadsheet Cell Background

Discussion in 'Other PC Software' started by virginia, 2007/02/26.

  1. 2007/02/26
    virginia Lifetime Subscription

    virginia Geek Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    1,102
    Likes Received:
    26
    I have created a simple spreadsheet containing 75 numbers (Bingo) that I would like to use with a laptop and projector at a retirement center. The numbers are static but I would like to use the mouse to display (toggle) a colored background as each number is called. Then when a game is over, use escape or some other command to return the background to default - ready for the next game.

    I am presently using Open Office Calc but also have Excel 97 on my machine that I could use. Spreadsheet may not be the best application for what I am trying to do but it seemed to be the simplest to construct a template. Does anyone have any help in solving the background issue for the way I am going now or suggestions for another application?
     
  2. 2007/02/28
    ReggieB

    ReggieB Inactive Alumni

    Joined:
    2004/05/12
    Messages:
    2,786
    Likes Received:
    2
    You could try this.
    1. Copy the spreadsheet (so you mess around and not destroy the original).
    2. In the copy of the spreadsheet all but the sheet you want to use (delete a sheet by right-clicking on its tab and selecting delete)
    3. Go into the Visual Basic Editor (Alt-F11 or Tools > Macros > Visual Basic Editor)
    4. Double click on the Sheet object in "Microsoft Excel Objects" (left top project pane). This should create a blank code page in the main pane of the Visual Basic Editor.
    5. Paste the code below onto that blank code page.
    6. Click on the save button, and change the file type to template (*.xlt)

    Here is the code
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        With ActiveCell.Interior
            .ColorIndex = 50
            .Pattern = xlSolid
        End With
    End Sub
     

  3. to hide this advert.

  4. 2007/02/28
    ReggieB

    ReggieB Inactive Alumni

    Joined:
    2004/05/12
    Messages:
    2,786
    Likes Received:
    2
    I had a problem here and completed that post a little quickly.

    That code changes the colour of the active cell. Every time the selection changes the code is triggered and the active cell changes colour (to green). Clicking on a new cell changes the selection, and therefore triggers the code. As the cell that you click on becomes the active cell, its colour changes. That might be a little difficult because it is switched on immediately. You could add to the code to check for an entry and only update the cells if an entry is present.

    See if that is the sort of thing you want. If it is, we can tweak it, to more closely match what you want.

    As the sheet is saved as a template, double clicking on sheet creates a new copy of the sheet. So at the start of the game, you double click on the template to open a blank sheet, make the entries through the game, and then close the sheet at the end of the game.
     
  5. 2007/03/01
    virginia Lifetime Subscription

    virginia Geek Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    1,102
    Likes Received:
    26
    Reggie B,

    Thanks for the response. Your code worked great. Also, thanks for your suggestion:

    As you suggested, I made a copy - and later I had to make another copy.

    Hopefully, we will be able to try it out this weekend. Thanks so much.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.