What is VBA OCT Function
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 from here.
how to use it
To use VBA's OCT function you need to understand its syntax and arguments:
- Number: An integer for which you want to convert to octal.
Example to use OCT Function in VBA
To practically understand how to use 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.
Below are some important points which you need to take care while using OCT function in VBA.
- 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.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.