Finance

Charts

Statistics

Macros

Search

Variable Names and Values In Excel VBA

A variable has a unique name by which it can be referenced in the code. In VBA, the following rules apply to variable names:

  • They must begin with a letter.
  • They can only contain letters, numbers, and a few special characters (for example, the underscore _).
  • They should not include German umlauts (ä, ö, ü) or the sharp s (ß).
  • Within a given scope, no two variables may share the same name (see section 5.1, « Scopes »).

Valid examples of variable names are: Temperature, Summe_Werte, or X12.

Invalid examples include: 5Tage (because it starts with a digit) or Tag#12 (because it contains an invalid character #).

Variables receive their values through assignment using the equal sign =. It is advisable to assign a value to a variable before its first use, for example:

Temperature = 25

Assigning values early makes programs clearer, easier to read, and less prone to errors.

 

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx