When you create a new file, all of the cells in the worksheet are of a general type. This means that when you enter a new value, Excel tries to guess whether you wanted to enter text, a numerical value, a date, etc.
I present which types of data you can use in VBA:
The text is the only data type in Excel that is, by default, aligned to the left. It is used mainly for naming table headers, descriptions, etc.
This type of data includes integers, fractions, percentages, currency, and other types of figures. These are the most common data types in most worksheets.
Dates and times
This type includes the date and time, stored in different formats. For example, the date with time: 2003-07-07 12:32:56 can also be saved as 2003-07-07 or July 7, 2003.
Those examples are just a few of many different dates and time combinations.
This data type can contain one of the two values: TRUE or FALSE. In the vast majority of cases, you won’t use this data type. It is useful when you work with the macro code. This value is, by default, centered.
If you want dates or numbers to be treated as text, you must precede the value with ” ‘ “, eg. ‘2013-12-12 or ‘28%.
Skillshare’s usually $10 a month, but because you’re an OfficeTuts reader you can get your first month free by clicking here. That’s unlimited access to over 18,000 classes on Excel, VBA, and much more.