User FAQs

If you have a question, please send it to us.

1) Is there any Microsoft documentation for VBA Programming ?

link - 

2) Is there a forum for questions about VBA Programming ?
Post your questions in the Microsoft Q&A forum with the topic "office-vba-dev".

link - 

There is also a forum on techcommunity. The Excel hub forum with the label "Macros and VBA".
The following labels also exist but should not be used "Macros & VBA" and "VBA".

link - 

There is also a forum on Stack Overflow with the tag "vba".

link - 

3) Should I indent my code with spaces or tabs ?
Always use tabs to indent your code to bring structure, never use spaces.

link - 

4) Do I really need to add comments ?
Try and put your comments on the same line, on the right hand side of the code.
And only add "value added" comments which explain why, do not add trivial comments.
Make the names of your subroutines, functions and variables self-describing.
Always add a Comment Block above every procedure and function.

5) What is Option Explicit and what does it do ?

Option Explicit 

Including this at the top of a module means that all variables must be explicitly declared using the Dim statement.
This statement only affects the module it is declared in.

6) What problems do you have if you don't use Option Explicit ?
Variables do not have to be declared before they are used.
Mistyping a variable name will create a new variable and will probably create a run-time error.

7) What is a Type Declaration Character ?
Also known as a variable declaration character or type declaration suffix.
It is possible to declare variables by appending a special character to the end of the variable name.

Dim iNumber@   'shorthand for As Currency  
Dim iNumber# 'shorthand for As Double
Dim iNumber% 'shorthand for As Integer
Dim iNumber& 'shorthand for As Long
Dim iNumber! 'shorthand for As Single
Dim iNumber^ 'shorthand for As LongLong - 64bit only
Dim iText$ 'shorthand for As String

8) What is a Literal Number Suffix ?
Also known as numeric literal suffixes.
When you use the Variant data type the compiler is able to determine the correct data type for a numerical literal however there might be times when the default data type is different to the desired one.

Dim myNumberV1 As Variant 
Dim myNumberV2 As Variant
myNumberV1 = 100
myNumberV2 = 100#

Debug.Print VBA.TypeName(myNumberV1) 'Integer
Debug.Print VBA.TypeName(myNumberV2) 'Double

9) What is the difference between a Literal Constant and a Symbolic Constant ?
A literal constant is a specific value such as a number, date or text.

Dim myDate As Date 
myDate = #12/31/2020#

A symbolic constant is a literal constant that is represented by a name.

Public Const sVALUE As String = "text" 

10) What is the difference between a Do-While loop and a Do-Until loop ?
In a Do-While loop the condition must be True.

Loop While boolean-expression = True

In a Do-Until loop the condition must be False.

Do Until boolean-expression = False 

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext