VBA Functions for Excel VBA Programming

The VBA language contains a number of functions that you can use to build code in Excel. The following table provides descriptions of the most useful functions. When writing code, type the word VBA followed by a period, and you'll see a drop-drop list of these functions. See Excel's Help system for more details.























































































































































































































































































































































































































































































VBA FunctionWhat It Does
AbsReturns the absolute value of a number
ArrayReturns a variant that contains an array
AscConverts the first character of string to its ASCII value
AtnReturns the arctangent of a number
CBoolConverts an expression to boolean
CByteConverts an expression to byte data type
CCurConverts an expression to currency data type
CDateConverts an expression to date data type
CDblConverts an expression to double data type
CDecConverts an expression to decimal data type
ChooseSelects and returns a value from a list of arguments
ChrConverts an ANSI value to a string
CIntConverts an expression to integer data type
CLngConverts an expression to long data type
CosReturns the cosine of a number
CreateObjectCreates an OLE Automation object
CSngConverts an expression to single data type
CStrConverts an expression to string data type
CurDirReturns the current path
CVarConverts an expression to variant data type
CVDateConverts an expression to date data type
CVErrReturns a user-defined error number
DateReturns the current system date
DateAddReturns a date with a specific date interval added to it
DateDiffReturns a date with a specific date interval subtracted from
it
DatePartReturns an integer containing a specific part of a date
DateSerialConverts a date to a serial number
DateValueConverts a string to date
DayReturns the day of the month of a date
DirReturns the name of a file or directory that matches a
pattern
DoEventsYields execution so the operating system can process other
events
EOFReturns True if the end of a text file has been reached
ErrorReturns the error message that corresponds to an error
number
ExpReturns the base of the natural logarithms (e) raised to
a power
FileAttrReturns the file mode for a text file
FileDateTimeReturns the date and time when a file was last modified
FileLenReturns the number of bytes in a file
FixReturns the integer portion of a number
FormatDisplays an expression in a particular format
Format CurrencyReturns a number as a string, formatted as currency
FormatDateTimeReturns a number as a string, formatted as a date and/or
time
Format NumberReturns a number as a formatted string
Format PercentReturns a number as a string, formatted as a percentage
FreeFileReturns the next file number available for use by the Open
statement
GetAllReturns a list of key settings and their values (originally
created with SaveSetting) from an application’s entry in the
Windows registry
GetAttrReturns a code representing a file attribute
GetObjectRetrieves an OLE Automation object from a file
GetSettingReturns a key setting value from an application’s entry
in the Windows registry
HexConverts from decimal to hexadecimal
HourReturns the hour of a time
IIfReturns one of two parts, depending on the evaluation of an
expression
InputReturns a specific number of characters from an open text
file
InputBoxDisplays a box to prompt a user for input
InStrReturns the position of a string within another string
InStrRevReturns the position of a string within another string,
beginning at the back end of the string
IntReturns the integer portion of a number
IsArrayReturns True if a variable is an array
IsDateReturns True if a variable is a date
IsEmptyReturns True if a variable has been initialized
IsErrorReturns True if an expression is an error value
IsMissingReturns True if an optional argument was not passed to a
Procedure
IsNullReturns True if an expression contains no valid data
IsNumericReturns True if an expression can be evaluated as a number
IsObjectReturns True if an expression references an OLE Automation
object
JoinReturns a string created by joining a number of substrings
contained in an array
LBoundReturns the lower bound of an array
LCaseReturns a string converted to lowercase
LeftReturns a specified number of characters from the left of a
string
LenReturns the length of a string, in characters
LocReturns the current read or write position of a text file
LOFReturns the number of bytes in an open text file
LogReturns the natural logarithm of a number
LTrimReturns a copy of a string with no leading spaces
MidReturns a specified number of characters from a string
MidBReturns a specified number of bytes from a string
MinuteReturns the minute of a time
MonthReturns the month of a date
MonthNameReturns a string indicating the specified month
MsgBoxDisplays a modal message box
NowReturns the current system date and time
OctConverts from decimal to octal
ReplaceReturns a string in which one substring is replaced with
another
RGBReturns a number representing an RGB color value
SpaceReturns a string with a specified number of spaces
SplitReturns an array consisting of a number of substrings
SqrReturns the square root of a number
StrReturns a string representation of a number
RightReturns a specified number of characters from the right of a
string
RndReturns a random number between 0 and 1
RoundRounds a number to a specific number of decimal places
RTrimReturns a copy of a string with no trailing spaces
SecondReturns the second of a time
SeekReturns the current position in a text file
SgnReturns an integer that indicates the sign of a number
ShellRuns an executable program
SinReturns the sin of a number
StrCompReturns a value indicating the result of a string
comparison
StrConvReturns a string variant converted as specified
StringReturns a repeating character or string
StrReverseReverses the character order of a string
SwitchEvaluates a list of expressions and returns a value associated
with the first expression in the list that is True
TabPositions output in an output stream
TanReturns the tangent of a number
TimeReturns the current system time
TimerReturns the number of seconds since midnight
TimeSerialReturns the time for a specified hour, minute, and second
TimeValueConverts a string to a time serial number
TrimReturns a string containing a copy of a specified string
without leading spaces and trailing spaces
TypeNameReturns a string that describes the data type of a
variable
UBoundReturns the upper bound of an array
UCaseConverts a string to uppercase
ValReturns the numbers contained in a string
VarTypeReturns a value indicating the subtype of a variable
WeekdayReturns a number representing a day of the week
Weekday NameReturns a string indicating the specified weekday
YearReturns the year of a date



dummies

Source:http://www.dummies.com/how-to/content/vba-functions-for-excel-vba-programming.html

No comments:

Post a Comment