Excel VBA - With

Card Puncher Data Processing

Example

' sets the border line style for cells A1:J10
With Worksheets(1)
    .Range(.Cells(1, 1), _
        .Cells(10, 10)).Borders.LineStyle = xlThick
End With

the period in front of each occurrence of the Cells property is required if the result of the preceding With statement is to be applied to the Cells property — in this case, to indicate that the cells are on worksheet one (without the period, the Cells property would return cells on the active sheet





Discover More
Card Puncher Data Processing
Excel - (Select|Selection)

The macro recorder will often create a macro that uses the Select method and the Selection property but in Visual Basic, it is usually not necessary to select cells before modifying them. The Select...
Card Puncher Data Processing
Excel - ActiveCell

The ActiveCell property of a worksheet returns a Range object that represents the cell that is active. You can apply any of the properties or methods of a Range object to the active cell Be careful to...
Card Puncher Data Processing
Excel VBA - Range

Range represents: a cell, a row, a column, a selection|selection of cells containing one or more contiguous blocks of cells, or a 3-D range. Range property: If you use a text argument...



Share this page:
Follow us:
Task Runner