Code does / does not use With-End With : Selection « Excel « VBA / Excel / Access / Word






Code does / does not use With-End With

 
Sub selectionDemo()
    Selection.HorizontalAlignment = xlCenter
    Selection.VerticalAlignment = xlCenter
    Selection.WrapText = True
    Selection.Orientation = 0
    Selection.ShrinkToFit = False
    Selection.MergeCells = False
    
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .ShrinkToFit = False
        .MergeCells = False
    End With
End Sub

 








Related examples in the same category

1.Get the address of selection
2.Is the current selection a Range
3.Determining the type of selected range
4.Returns a count of all cells in a selection: using the Selection and Count properties
5.Returns a count of the number of rows in a selection
6.Returns a count of the number of columns in a selection
7.Counts columns in a multiple selection
8.To add a range name based on a selection
9.Get selection address
10.Toggling a Boolean property
11.Selection move down
12.Find next heading