Excel: Log Function
In Excel, the Log function returns the logarithm of a number to a specified base.
The syntax for the Log function is:
Log( number, base )
number is a numeric value that must be greater than 0.
base is optional. This is the base to use to calculate the logarithm of a number. If this parameter is omitted, the Log function will use a base of 10.
Applies To:
- Excel 2007, Excel 2003, Excel XP, Excel 2000
For example:
Let's take a look at an example:

Based on the Excel spreadsheet above:
=Log(A1) would return 1.301029996 =Log(A1, 10) would return 1.301029996 =Log(A1, A2) would return 0.930676558 =Log(A2, 5.1) would return 1.975690972 =Log(200, 3) would return 4.822736302
VBA Code
The Log function can also be used in VBA code. However in VBA, the Log function returns the natural logarithm of a number.
The syntax for the Log function in VBA is:
Log( number )
number is a numeric value that must be greater than 0.
For example:
Dim LResult As Double
LResult = Log(20)
In this example, the variable called LResult would now contain the value 2.995732274.
