Share this page:

MS Excel: LOG Function (WS, VBA)

Learn how to use the Excel LOG function with syntax and examples.

Description

The Microsoft Excel LOG function returns the logarithm of a number to a specified base.

Syntax

The syntax for the Microsoft Excel LOG function is:

LOG( number, [base] )

Parameters or Arguments

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

The LOG function can be used in the following versions of Microsoft Excel:

  • Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Excel Function

The LOG function can be used in Microsoft Excel as the following type of function:

  • Worksheet function (WS)
  • VBA function (VBA)

Example (as Worksheet Function)

Let's look at some Excel LOG function examples and explore how to use the LOG function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the spreadsheet above, the following Excel LOG examples would return:

=LOG(A1)
Result: 1.301029996

=LOG(A1, 10)
Result: 1.301029996

=LOG(A1, A2)
Result: 0.930676558

=LOG(A2, 5.1)
Result: 1.975690972

=LOG(200, 3)
Result: 4.822736302

Example (as VBA Function)

The LOG function can also be used in VBA code in Microsoft Excel. However in VBA, the LOG function returns the natural logarithm of a number and its syntax is different than the worksheet function.

Syntax (as a VBA Function)

The syntax for the Microsoft Excel LOG function in VBA code is:

Log( number )

Parameters or Arguments

number is a numeric value that must be greater than 0.

Let's look at some Excel LOG function examples and explore how to use the LOG function in Excel VBA code:

Dim LResult As Double

LResult = Log(20)

In this example, the variable called LResult would now contain the value 2.995732274.