You are on page 1of 1

VBA

Conditional statement If Else.


Executed when condition cond1, cond2 is true
If cond1 Then

ElseIf cond2 Then

Else

End If
Conditional statement Select Case.
It is executed when expression var == val

Function which doesnt return a value


Function functionName (arg1 As Typ1, arg2 As Typ1, )

End Function
Function which returns a value type of Typ
Function functionName (arg1 As Typ1, ) As Typ
Dim var As Typ

functionName = var
End Function
Operators

Select Case var


Case val1

Case val2

Case Else

End Select
Loops For, Do While.
It is executed until counter equals end.
For counter = start To end [ Step step]

Next counter
[]- optional by default step = 1
Loop Do While.
It is executed until condition cond is true.
Do While cond

Loop
Do

Loop While cond

And
- logical AND
Or
- logical OR
<>
- not equal to
=
- Basic assignment
=
- Equal to
Not
- Logical negation NOT
> , < , >= , <= - other comparison operators
+, -, * , / , ^ - mathematical operators
Typy zmiennych:
Integer - integer number
Double - A double-precision floating point value
String - chain of characters
Definition of a variable type of Typ
Dim var As Typ
Useful objects:
Cells (row, cols)
- reference to the cell with
coordinates (row_number, column_number)
MsgBox (message) - displays a window with the
message
InputBox (message) displays a window with the
message and a field in which a data can be input
Randomize
- it provides generation of
pseudorandom numbers
General file structure

Loop Do Until.
It is executed until condition cond is false.
Do Until cond

Loop
Do

Loop Until cond

Sub subName()

End Sub
Other:
comment

You might also like