Skip to content

Excel VBA – Working on Rows and Columns

    Insert Row/Column

    Inserts row/s above

    Range("A1").EntireRow.Insert
    Range("A1:A3").EntireRow.Insert

    Inserts column/s to the left

    Range("A1").EntireColumn.Insert
    Range("A1:A3").EntireColumn.Insert

    Delete Row/Column

    As Insert, but using the Delete method

    Insert Cells

    Range("A1:C1").Insert xlShiftDown
    Range("A1:A10").Insert xlShiftToRight

    Delete Cells

    Range("A1:E1").Delete xlShiftUp
    Range("A1:A10").Delete xlShiftToLeft

    Resize Row/Column

    Range("A1:E1").ColumnWidth = 30
    Range("A1:A10").RowHeight = 20

    Autofit columns

    Range("A1:E1").Columns.AutoFit

    or

    Columns("A:E").AutoFit

    Hide Row/Column

    Columns("A:E").Hidden = True
    Rows("1:5").Hidden= True