Hungarian variable names

Tags
Summary

"Sales tax rate" is sSalesTaxRate. Price is just sPrice.

Situation

You need to name some variable names.

Needs

A cell in a worksheet.

Action

The first character tells you the data type of the variable.

Type Start with Example Notes
Single s Dim sGoatWeight As Single
String t Dim tGoatName As String t stands for "text." s is already being used for Single.
Range r Dim rGoatData As Range

After the data type letter, use one or more words. The first character of each word is uppercase, like tGoatEyeColor.

Use names that explain what the variable means. E.g., for interest rate, use sInterestRate. For total sales, use sTotalSales. For high score, use sHighScore.

Don't use abbreviations that aren't normal English. For example, instead of tGtLn, use tGoatLastName.

Don't forget Ctrl+Space when you're writing code. Type the first few characters of a variable's name, then hit Ctrl+Space. VBE will show you the symbols that start with those characters. Faster, and fewer spelling errors.

Where referenced