How to work with and modify numbers in excel VBA?


vba Addition, Subtraction, Division, Multiplication, Power, Exp, Modulo remainder.

Numbers in VBA is quite intuitive. like normal math really.

Below are some examples of your normal math operations

Addition

Just use the normal '+' sign.

Subraction

Just use the normal '-' sign.

Division

Just use the normal '/' sign.

Multiplication

Just use the normal '*' sign.

Power

Just use the normal '^' sign.

Exponential

EXP function returns e raised to the nth power, where e = 2.7182..

MsgBox (Exp (0)) 'returns 1
MsgBox (Exp (1)) 'returns  2.71828182845905.

Modulo

The modulo operation returns the remainder of a division. Practical for determining even or odd numbers.

MsgBox (10 Mod 2) 'returns 0 as it is evenly divided. 
MsgBox (7 Mod 2) 'returns 1 as it is evenly divided three times, with 1 as remainder. 

2 views0 comments