Algoritmos
Use Range(arg), where arg names the range, to return a Range object that represents a single cell or a range of
cells. The following example places the value of cell A1 in cellA5.
W orksheets("Sheet1").Range("A5").Value = W orksheets("Sheet1").Range("A1").Value
The following example fills the range A1:H8 with random numbers by setting the formula for each cell in therange. When it's used without an object qualifier (an object to the left of the period), the Range property
returns a range on the active sheet. If the active sheet isn't a worksheet, the methodfails. Use the Activate
method to activate a worksheet before you use the Range property without an explicit object qualifier.
Worksheets("Sheet1").Activate
Range("A1:H8").Formula = "=Rand()"'Range is on the active sheet
The following example clears the contents of the range named Criteria.
Worksheets(1).Range("Criteria").ClearContents
A. DECLARE A RANGE
Use the keywords Dim andSet.
Dim example as range
Set example = Range(“A1:D1”)
B. SELECT A RANGE
The selection method selects a range.
Dim example as Range
Set example = Range(“A1:C4”)
example.select
C. COLUMNWIDTH /ROW HEIGHT PROPERTY
Use ColumnWidth/RowHeight to set the column width of every other column on Sheet1 to a specific size.
Worksheets("Sheet1").Columns(1).ColumnWidth = 10Worksheets("Sheet1").Rows(3).RowHeight = 40
D. OTHER COMMON RANGE METHODS
Bold / Italic
Range("A1").Font.Bold = True
Range("A1").Font.Bold = False
Range("A1").Font.Italic = True
Range("A1").Font.Italic =False
Horizontal Alignment
Range("A1").HorizontalAlignment = xlCenter
Range("A1").HorizontalAlignment = xlLeft
Range("A1").HorizontalAlignment = xlRight
Color IndexRange("A1").Font.ColorIndex = 3
Borders
Range("A1").Borders.LineStyle = xlContinuous
Range("A1").Borders.LineStyle = xlDouble
Range("A1").Borders.LineStyle = xlDash
Range("A1").Borders.LineStyle = xlDashDot...
Regístrate para leer el documento completo.