Vba And Excel Object Model Quick Reference

VBA FUNCTION QUICK REFERENCE (CONTINUED)

Data Type Conversion Functions (Continued)

FUNCTION

DESCRIPTION

RETURNS

CLng(expression)

Converts an expression to the Long data type.

Long

CSng(expression)

Converts an expression to the Single data type.

Single

CStr (expression )

Returns a string containing the specified expression.

String

CVar (expression)

Converts any data type to a Variant data type. All numeric values are treated as Double data types and string expressions are treated as String data types.

Variant

Format(expression[, format[, firstdayofweek[, firstweekofyear]]])

Formats the expression using either predefined or user-defined formats.

Variant

FormatCurrency (Expression [, NumDigitsAfterDecimal [, IncludeLeadingDigit [,UseParensForNegativeNumbers [, GroupDigits]]]])

Formats the expression as a currency value using the system-defined currency symbol.

Currency

FormatDateTime(Date[, NamedFormat])

Formats an expression as a date and time.

Date

FormatNumber- (Expression [, NumDigitsAfterDecimal [, IncludeLeadingDigit [, UseParensForNegativeNumbers [, GroupDigits]]]])

Formats the expression as a number.

Mixed

FormatPercent (Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

Returns the expression formatted as a percentage with a trailing % character.

String

Hex(number)

Converts a number to a hexadecimal value. Rounds numbers to nearest whole number before converting.

String

Oct(number)

Converts a number to an octal value. Rounds numbers to nearest whole number before converting.

Variant (String)

Str(number)

Converts a number to a string using the Variant . data type

Variant

(String)

Val(string)

Returns the numeric portion of a string formatted as a number of the appropriate data type.

Mixed

VBA QUICK REFERENCE

VBA FUNCTION QUICK REFERENCE (CONTINUED)_

Date and Time Functions

FUNCTION

DESCRIPTION

RETURNS

Date

Returns the current system date.

Date

DateAdd(interval, number, date)

Returns a date that is the specified interval of time from the original date.

Date

DateDiff (interval, date1, date2[, firstdayofweek[, firstweekofyear]])

Determines the time interval between two dates.

Long

DatePart(interval, date[, firstdayofweek[, firstweekofyear]])

Returns the specified part of a date.

Integer

DateSerial(year month, day)

Converts the specified date to a serial number.

Date

DateValue(date)

Converts a string to a date.

Date

Day(date)

Returns a whole number between 1 and 31 representing the day of the month.

Integer

Hour(time)

Returns a whole number between 0 and 23 representing the hour of the day.

Integer

Minute(time)

Returns a whole number between 0 and 59 representing the minute of the hour.

Integer

Month(date)

Returns a whole number between 1 and 12 representing the month of the year.

Integer

Now

Returns the current system date and time.

Date

Second(time)

Returns a whole number between 0 and 59 representing the second of the minute.

Integer

Time

Returns the current system time.

Date

Timer

Indicates the number of seconds that have elapsed since midnight

Single

TimeSerial(hour minute, second)

Creates a time using the specified hour, minute, and second values.

Date

TimeValue(time)

Converts a time to the serial number used to store time.

Date

WeekDay(date, [firstdayofweek])

Returns a whole number representing the first day of the week.

Integer

Year(date)

Returns a whole number representing the year portion of a date.

Integer

0 0

Post a comment