Search notes:

Excel VBA: Influence of deleting a rows/columns on a range

This example tries to demonstrate how a range object is influenced if rows or columns of the worksheet that the range is created from are deleted.
It turns out that the worksheet shrinks according to the deleted rows and columns.
option explicit

sub main() ' {

    dim rng as range
    set rng = [ r3c2:r5c6 ]

    rng.interior.color = rgb(255, 190, 60)

    cells(6,2) = "Dimensions before deleting: " & rng.rows.count & " x " & rng.columns.count

    columns(4).delete
    rows(4).delete

    cells(6,2) = "Dimensions after deleting: " & rng.rows.count & " x " & rng.columns.count

    rng.borderAround weight := xlThick, color := rgb(220, 140, 30)

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Range/modify.bas

Index