Home / vba userform code cheat sheet / VBA for Excel Cheat Sheet

VBA for Excel Cheat Sheet - vba userform code cheat sheet

VBA for Excel Cheat Sheet -vba userform code cheat sheet

VBA for Excel Cheat Sheet
by guslong via cheatography.com/1345/cs/510/
VBA data types Iterate through a selection String functions
Type Description Dim cell As Range InStr ([start], "string", "wha Returns position of
Variant any data type For Each cell In Selection t_to_find") string within a string
Integer (2 bytes) integer
... StrConv("string", vbProper| converts string to proper
Next cell Upper|LowerCase) |upper|lower case
Long (4 bytes) integer
Single (4 bytes) floating point Control structures VBA Left ("string", x) Return specified
Double (8 bytes) floating point Do ... Until Loop
Len ("string") Return length of string
String non-numeric data
Trim ("string") Trims string of leading
Object any object reference Do [Until condition] and trailing spaces
... Split("string", ",") Split string by delimiter
Date a date Loop e.g. comma
Boolean True / False Val("string") Return numerical part
Byte 1-255 Do ... While Loop only
Do [While condition] StrComp("strA", "strB", Compare two strings
Cell selection ... vbTextCompare) (0=true)
select a single cell
Range("A1").Select For...Next Loop VBA information functions
select a contiguous range For counter = start To end [Step s] IsArray
Range("A1:G5").Select ... IsEmpty
select a non-contiguous range
Next [counter]
Range("A1:G5,J10:J15").Select "WITH" syntax IsMissing
offset syntax (move from A1 to A2)
Range("A1").Offset(1,0).Select With Worksheets("Sheet1") IsNumeric
select down to first empty cell .Rows IsNull
Range(Selection, Selection.End(xlDown)).Select .Columns IsObject
set a cell's value End With
Range("A1").Value = i
The "with" construction provides a shorthand way of
deleting, moving, copying (VBA) accessing many properties and methods of the same
Delete entire row
Delete entire column
Copy / paste a range with destination
Range("A1:B6").Copy Destination:=Range("A1")
Clear a range
Delete a worksheet
Execute a formula calculation in a range
Range("A1:A3").Formula = 2*2/6
Use RANGE to select single cells.
Cheatographer Cheat Sheet Sponsor
guslong This cheat sheet was published on 13th August, 2012 FeedbackFair, increase your conversion rate today!
cheatography.com/guslong/ and was last updated on 13th August, 2012. Try it free!