Moving Around in Excel
Exercise 2.01

Exercise 2.01

The aim of this exercise is to play a game of Battleships by selecting and changing the colour of cells in a worksheet.

Files Needed

Click here to download the file needed for this exercise.

Instructions

  1. Extract and open the Battleships Game.xlsm workbook.
Game

The game contains a grid of 10x10 cells, some of which are populated by "ships".

  1. Create a subroutine called Sink_Sub which does the following:
  • Use the Cells property to select the submarine in cell H4.
  • Change the fill colour of the selected cell to red.
  1. Create a subroutine called Sink_Destroyers which does the following:
  • Use the Range property to select the three destroyers.
  • Change the fill colour of the selected cells to red.
  1. Create a subroutine called Sink_Aircraft_Carrier which does the following:
  • Use the Cells or Range property to select cell E6.
  • Use the End property to extend the selection to select the entire aircraft carrier.
  • Change the fill colour of the selected cells to red.
  1. Create a subroutine called Sink_Battleship which does the following:
  • Changes the fill colour of the cells containing the battleship to red without selecting the cells.
  1. Run each subroutine and check that the results appear as in the diagram below:
Result

After running every subroutine, your worksheet should resemble this one.

 
  1. Save and close the file.

Answer Files

Click here to download a file containing a suggested answer.

This page has 0 threads Add post