Sub Time_Now()
Dim s As String
s = Now()
Cells(1, 1) = s
End Sub
Press | To Do This | Press | To Do This |
---|---|---|---|
Alt+F11 | Open the VBA editor | F1 | Get help on any selected item |
Alt+F8 | Display a list of macros | F2 | Display the Object Browser window |
Ctrl+Break | Perform an emergency stop of the program | F4 | Display the Properties window |
Ctrl+G | Display the Immediate window | F5 | Start the program |
Ctrl+I | List the quick information for the selected element | F7 | Display the Code window after selecting a form or control |
Ctrl+J | List the properties and methods for an object | F9 | Add a breakpoint |
Ctrl+R | Display Project Explorer | Shift+F7 | Display the form that corresponds to the active Code window |
Ctrl+Shift+I | List the parameter information for the selected element | Shift+F9 | Add a quick watch for the highlighted text |
Ctrl+Shift+J | List the constants associated with an enumeration | Ctrl+Tab | Move to the next Code or UserForm window |
Function | What It Does |
Abs | Returns a number's absolute value |
Array | Returns a variant containing an array |
Asc | Converts the first character of a string to its ASCII value |
Atn | Returns the arctangent of a number |
Choose | Returns a value from a list of items |
Chr | Converts an ANSI value to a string |
Cos | Returns a number's cosine |
CurDir | Returns the current path |
Date | Returns the current system date |
DateAdd | Returns a date to which a specified time interval has been |
added — for example, one month from a particular date | |
DateDiff | Returns an integer showing the number of specified time intervals between two dates, for example the number of months between now and your birthday |
DatePart | Returns an integer containing the specified part of a given |
date — for example, a date's day of the year | |
DateSerial | Converts a date to a serial number |
DateValue | Converts a string to a date |
Day | Returns the day of the month from a date value |
Dir | Returns the name of a file or directory that matches a pattern |
Erl | Returns the line number that caused an error |
Err | Returns the error number of an error condition |
Error | Returns the error message that corresponds to an error number |
Exp | Returns the base of the natural logarithm (e) raised to a power |
FileLen | Returns the number of bytes in a file |
Fix | Returns a number's integer portion |
Format | Displays an expression in a particular format |
GetSetting | Returns a value from the Windows registry |
Hex | Converts from decimal to hexadecimal |
Hour | Returns the hours portion of a time |
InputBox | Displays a box to prompt a user for input |
InStr | Returns the position of a string within another string |
Int | Returns the integer portion of a number |
IPmt | Returns the interest payment for an annuity or loan |
IsArray | Returns True if a variable is an array |
IsDate | Returns True if an expression is a date |
IsEmpty | Returns True if a variable has not been initialized |
IsError | Returns True if an expression is an error value |
IsMissing | Returns True if an optional argument was not passed to a procedure |
IsNull | Returns True if an expression contains no valid data |
IsNumeric | Returns True if an expression can be evaluated as a number |
IsObject | Returns True if an expression references an OLE Automation object |
LBound | Returns the smallest subscript for a dimension of an array |
LCase | Returns a string converted to lowercase |
Left | Returns a specified number of characters from the left of a string |
Len | Returns the number of characters in a string |
Log | Returns the natural logarithm of a number to base e |
LTrim | Returns a copy of a string, with any leading spaces removed |
Mid | Returns a specified number of characters from a string |
Minute | Returns the minutes portion of a time value |
Month | Returns the month from a date value |
MsgBox | Displays a message box and (optionally) returns a value |
Now | Returns the current system date and time |
RGB | Returns a numeric RGB value representing a color |
Right | Returns a specified number of characters from the right of a string |
Rnd | Returns a random number between 0 and 1 |
RTrim | Returns a copy of a string, with any trailing spaces removed |
Second | Returns the seconds portion of a time value |
Sgn | Returns an integer that indicates a number's sign |
Shell | Runs an executable program |
Sin | Returns a number's sine |
Space | Returns a string with a specified number of spaces |
Sqr | Returns a number's square root |
Str | Returns a string representation of a number |
StrComp | Returns a value indicating the result of a string comparison |
String | Returns a repeating character or string |
Tan | Returns a number's tangent |
Time | Returns the current system time |
Timer | Returns the number of seconds since midnight |
TimeSerial | Returns the time for a specified hour, minute, and second |
TimeValue | Converts a string to a time serial number |
Trim | Returns a string without leading or trailing spaces |
TypeName | Returns a string that describes a variable's data type |
UBound | Returns the largest available subscript for an array's dimension |
UCase | Converts a string to uppercase |
Val | Returns the numbers contained in a string |
VarType | Returns a value indicating a variable's subtype |
Weekday | Returns a number representing a day of the week |
Year | Returns the year from a date value |
Value Explanation 1 Absolute referencing.
For example: $A$12 Absolute row; relative column.
For example: $A13 Relative row; absolute column.
For example: A$14 Relative referencing.
For example: A1
Value Explanation TRUE A1 style referencing FALSE R1C1 style referencing
=ADDRESS(4, 5) would return "$E$4" =ADDRESS(4, 5, 1) would return "$E$4" =ADDRESS(4, 5, 2) would return "E$4" =ADDRESS(4, 5, 3) would return "$E4" =ADDRESS(4, 5, 4) would return "E4" =ADDRESS(4, 5, 1, TRUE) would return "$E$4" =ADDRESS(4, 5, 1, FALSE) would return "R4C5" =ADDRESS(4, 5, 1, TRUE, "Sheet1") would return "Sheet1!$E$4"
Custom Cell Formats | Text Before Formatting | Custom Format | Formatted Text |
Brackets for negative values | -500 | #,##0;(#,##0) | (500) |
Red and brackets for negative values | -500 | #,##0.00;[Red](#,##0.00) | (500.00) |
Day of the week in full | 27/03/2010 | dddd | Saturday |
Day, date, month and year | 27/03/2010 | ddd dd mmm yyyy | Sat 27 Mar 2010 |
Month | 27/03/2010 | mmmm | March |
Phone Numbers | 755551234 | 00 0000 0000 | 07 5555 1234 |
Phone Numbers with Brackets | 755551234 | (00) 0000 0000 | (07) 5555 1234 |
Fractions | 10.5 | # ??/?? | 10 1/2 |
Share this with your friends and colleagues on Twitter, and Facebook etc. using the shortcuts below. |