Excel Prank - Hide Text on Cell Selection

Add to Favorites
Author: don | Edits: don

This prank will hide the contents of the currently selected cell and then show the contents once another cell is selected.

No data is changed or deleted using this prank, only the font color of the cell will be changed.

Before cell selection:


After cell selection (B2):


After next cell selection (C1):



The Prank Macro Code

Where to Install


The Prank Macro Code

Public oldColor As Long
Public oldCell As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'secondary cell selection - changes the font back to its original color
If Not oldCell = Empty Then

    'set the color of the original font
    Range(oldCell).Font.Color = oldColor

End If

'set the old cell
oldCell = Target.Address
'set the old color
oldColor = Target.Font.Color

'get the background color
newColor = Target.Interior.Color
'set the font to the background color
Target.Font.Color = newColor

End Sub

The top 2 lines of this code must go at the very top of the code window, above all macros.


Note: this goes into a Worksheet code section and not a Module, look to the next section for instructions.

Where to Install

Worksheet code section.

Install this into the worksheet on which you want the prank to work.

Alt + F11 (VBA window) > look to the Project window on the left side of the window (Ctrl + R if you don't already see it) > double-click the name of the worksheet where you want this prank to work > put the code into the window that opens.



This macro will only work on the worksheet or worksheets where you insert the code in the VBA window; you can't just apply it to the entire workbook at once.

Also, the macro works in the SelectionChange event; if you already have code in that event, then just copy/paste the above code without the lines that begin with Sub and End Sub.

The only way to stop this prank is to remove the code from the workbook or disable macros.

Download the attached file to see this macro in action.

Question? Ask it in our Excel Forum

Downloadable Files: Excel File