Fresh Excel Tips

Quick and Easy Excel Tips and Tutorials

How to Use and Define Loops with correct Syntax in Excel VBA

Today, we will be discussing how to use and define loops in Excel VBA. Below is an example of a basic For loop. For i = 1 To n ' Code goes here Next i For loops are sometimes called For Next loops because you use the Next statement to bound the code over [...]

How to Use IF/then/Else Conditional Statements in Excel VBA

Below, we will illustrate a few examples on how to use IF/then/Else statements: If (time = 32000) then ' Statements go here End If If (MyCondition = True) Then ' Statements Else ' More statements End If If (count < 10) Then ' Statements ElseIf (count < 20) Then ' Statements ElseIf [...]

How to Define Constants using the correct syntax in Excel VBA

In this article, we will be discussing how to define and use constants in Excel VBA. VBA constants are declared using the syntax Const Name As DataType = Value, as shown in the example below: Const ThisConstant As Integer = 7 Public ThisConstant2 As Double = 3.189 Just as with [...]

How to define Variables in Excel VBA using the Dim statement

For this article, we are going to discuss how to use the proper syntax for declaring variables in Excel VBA. To do this, we will need to use the Dim statement. as shown in the example below: Dim apple As Double Dim basket As Integer Dim statements are of the general form Dim VariableName As DataType, where [...]