What is the syntax to format number output?

 Format(<value>, "<formatting convention>")
'example - outputs 2
decimalNum = 2.31321
Msgbox Format(decimalNum, "0")

 

Advertisements

What is the syntax to find the maximum between two numbers?

<variable to hold maximum> = WorksheetFunction.Max(<num1>, <num2>)
#example 
maxValue= WorksheetFunction.Max(100, Sheets("eg").Cells(1,1).value)

What is the syntax to generate a random number?

<variable holding number> = (<max> - <min> + 1) * Rnd + <min>
'where max is the highest value the random number can be
'where min is the lowest value the random number can be
'cast to Int if a non-decimal random is desired
'examples

Dim myNumber As Integer
myNumber = Int ((20 - 10 + 1) * Rnd + 10)
'examples of values generated: 12, 10, 20, 23

Dim myNumber As Double
myNumber = (20 - 10 + 1) * Rnd + 10
'examples of values generated: 12.2, 10.2, 10, 20, 19.3, 12.2