Beruflich Dokumente
Kultur Dokumente
VBA data types deleting, moving, copying (VBA) (cont) String functions
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
Range("A1:B6").Copy
Destination:=Range("A1")
Clear a range
Range(D:D").Clear