Steganography with Excel VBA

Steganography is the practice of hiding a file, message or other data within an overlying file, message, or data.  It is related to cryptography, but is not the same.  Encrypted communications can draw attention to the fact that they are encrypted.  Steganography enables hidden communications within seemingly innocuous or conventional messages or data.

As a practice exercise in Excel VBA, I have created a spreadsheet utility that will hide numeric data within an array of semi-random digits.  The results are probably closer to cryptography than true steganography.  My project is more about exploring and teaching with VBA than advancing the science of cryptography.  My humble work is available for your inspection on both GitHub and Google Drive.


The general idea is to be able to carry a table of figures that contains numbers that I need to access occasionally, would like to carry in a simple readable format, but would like to keep secure.  These could be Social Security numbers, bank account numbers, lock codes, etc.


When I need to access a number that I can’t remember, I only need to pull out my chart, refer to the proper row or column, and read out the digits.  To an uninformed third party, my chart is just a table of random digits.  To a semi-informed third party, the use of the chart may be understandable, but the specific row or column is not likely to be easily decipherable.

Spreadsheet Utility

The spreadsheet provides a 14 x 20 matrix of single digit cells that looks something like a Sudoku exercise.  The user can enter as many account codes as desired.  The codes could be entered as a rows of single digits, or columns of single digits, or diagonal ranks of single digits, or even some complicated combination of rows, columns, and diagonals.  The user can mark selected cells with random background colors or bold font to indicate proximity to where a row or column sequence might start or end.  (The user can also mark additional decoy cells with color or bold font.)  The utility will then fill in the rest of the table with random digits.

VBA Code

I banged out this code in about an hour, with a focus on simplicity.  I have embraced the latest 21st Century philosophy of Camel case without Hungarian notation.  I have avoided the more elaborate variable naming and comment structuring generally required for large projects, but I believe the code as commented is still quite readable.

The code is primarily built around four macros used to clear and build the table.  Each macro is called using a button on the main worksheet.

The first macro (called by the “Clear Contents” button) clears out the table in order to get started.  There is not really anything interesting to see here.

The second macro (called by the “Mark Random Light Color” button) may be the most interesting.  This macro enables the user to select specific cells and set their background colors to random pastel colors.  It generates three random numbers corresponding to the the red, green, and blue (RGB) color intensities.  The range of the random numbers is intentionally limited to the “brighter” range of the spectrum, so that the resulting pastel color will light enough for a black font to be legible upon that color.

The third macro (called by the “Steganize” button) uses nested loops to cycle through every cell in the table.  If the user has not already placed a character in a cell, the code will assign a single random digit between 0 and 9.

The fourth macro (called by the “Mark Bold” button) is the most boring macro.  It changes the font of the selected cell to bold.

An additional private subroutine detects the file open event and displays a welcome message box.

I hope you find this utility amusing, educational, or perhaps even useful.

(Image courtesy of the3cats at Pixabay.)