0% found this document useful (0 votes)
89 views1 page

VBA For Excel Cheat Sheet: by Via

This document provides a cheat sheet on VBA for Excel with information on: 1) VBA data types like variants, integers, strings, objects, and dates. 2) Methods for selecting cells and ranges in Excel like selecting a single cell or contiguous/non-contiguous ranges. 3) Common string functions in VBA like Left, Len, Trim, and Split.

Uploaded by

mic_manos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views1 page

VBA For Excel Cheat Sheet: by Via

This document provides a cheat sheet on VBA for Excel with information on: 1) VBA data types like variants, integers, strings, objects, and dates. 2) Methods for selecting cells and ranges in Excel like selecting a single cell or contiguous/non-contiguous ranges. 3) Common string functions in VBA like Left, Len, Trim, and Split.

Uploaded by

mic_manos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

VBA for Excel Cheat Sheet

by guslong via cheatography.com/1345/cs/510/

VBA data types deleting, moving, copying (VBA) (cont) String functions

Type Description Delete a worksheet InStr ([start], "string", Returns position of

Worksheets("Sheet2").Delete "what_to_find") string within a string


Variant any data type
StrConv("string", converts string to
Integer (2 bytes) integer Execute a formula calculation in a range
vbProper|Upper|Lower proper|upper|lower
Long (4 bytes) integer Range("A1:A3").Formula = 2*2/6 Case) case
Single (4 bytes) floating point
Use RANGE to select single cells. Left ("string", x) Return specified
Double (8 bytes) floating point
Len ("string") Return length of
String non-numeric data Iterate through a selection string

Object any object reference Dim cell As Range Trim ("string") Trims string of
For Each cell In Selection leading and trailing
Date a date
... spaces
Boolean True / False
Next cell Split("string", ",") Split string by
Byte 1-255
delimiter e.g. comma
Control structures VBA Val("string") Return numerical
Cell selection
Do ... Until Loop part only
select a single cell Do [Until condition] StrComp("strA", Compare two strings
Range("A1").Select ... "strB", (0=true)
Loop vbTextCompare)
select a contiguous range
Do ... While Loop
Range("A1:G5").Select Do [While condition] VBA information functions
select a non-contiguous range ...
IsArray
Loop
Range("A1:G5,J10:J15").Select
For...Next Loop IsEmpty
offset syntax (move from A1 to A2) For counter = start To end [Step s] IsError
Range("A1").Offset(1,0).Select ...
IsMissing
Next [counter]
select down to first empty cell IsNumeric
Range(Selection, "WITH" syntax IsNull
Selection.End(xlDown)).Select
IsObject
With Worksheets("Sheet1")
set a cell's value .Rows
Range("A1").Value = i .Columns
...
End With
deleting, moving, copying (VBA)
The "with" construction provides a shorthand
Delete entire row
way of accessing many properties and
Rows("2").Delete
methods of the same object.
Delete entire column

Columns("B").Delete

Copy / paste a range with destination

Range("A1:B6").Copy
Destination:=Range("A1")

Clear a range

Range(D:D").Clear

By guslong Published 13th August, 2012. Sponsored by CrosswordCheats.com


cheatography.com/guslong/ Last updated 5th June, 2014. Learn to solve cryptic crosswords!
Page 1 of 1. http://crosswordcheats.com

You might also like