VBA OCT Function (Syntax + Example)


- Written by Puneet (Last Updated: June 22, 2023)

The VBA OCT function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it can convert a number into octal notation () and return the value as a string. You can learn more about the octal numeral system here.




  • Number: An integer for which you want to convert to octal.


To practically understand how to use the VBA OCT function, you need to go through the below example where we have written a vba code by using it:

Sub example_OCT()
Range("A1").Value = Oct(989)
Range("A2").Value = Oct("&H3E6")
End Sub

In the above example, we have used the OCT to convert decimals to octal and hexadecimal to octal.


  • If the value specified is a value other than a number or a number that can’t be recognized as a number, VBA will return the run-time 13 error.
  • If the supplied number is not a whole number then it will be rounded to the nearest whole number.
Last Updated: June 22, 2023