Return to VBA Code Examples

VBA Hour Function

Hour Description

Returns the hours (a number from 0 to 23) from a time value.

Simple Hour Examples

Here is a simple Hour example:

This will return 5.

Hour Syntax

In the VBA Editor, you can type  “Hour(” to see the syntax for the Hour Function:

The Hour function contains an argument:

Time: A valid time.

Examples of Excel VBA Hour Function

Result: 15

Result: 17

Result: 6

Result will be the hour of the current system time.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!