The With/End With Structure : With « Language Basics « VBA / Excel / Access / Word






The With/End With Structure

 
Sub withEnd()
    Range("A1:A10").Font.Bold = True
    Range("A1:A10").Font.Color = vbBlue
    Range("A1:A10").Font.FontStyle = "Italic"
    Range("A1:A10").Font.Size = 14
    Range("A1:A10").Font.name = "Comic Sans Serif"
    
    With Range("A1:A10").Font
        .Bold = True
        .Color = vbBlue
        .FontStyle = "Italic"
        .Size = 14
        .name = "Comic Sans Serif"
    End With
End Sub

 








Related examples in the same category

1.Use nested with statement
2.Use a With...End With construct with fully qualified properties